{
if (argc == 2 && strcmp(argv[1], "-q") == 0)
do_output = 0;
- pthread_t pro[2], con[2];
+ pthread_t pro[2];
+ pthread_t con[2];
pthread_mutex_init(&mutex, NULL);
sem_init(&empty, 0, BufferSize);
sem_init(&full, 0, 0);
int ids[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // The identity of each thread (for debug messages)
for (int i = 0; i < ProducerCount; i++)
- pthread_create(&pro[i], NULL, (void*)producer, (void*)&ids[i]);
+ pthread_create(&pro[i], NULL, (void*)&producer, (void*)&ids[i]);
for (int i = 0; i < ConsumerCount; i++)
- pthread_create(&con[i], NULL, (void*)consumer, (void*)&ids[i]);
+ pthread_create(&con[i], NULL, (void*)&consumer, (void*)&ids[i]);
for (int i = 0; i < ProducerCount; i++)
pthread_join(pro[i], NULL);
sem_destroy(&full);
return 0;
-}
\ No newline at end of file
+}
simgrid::mc::AppSide::initialize();
#endif
- static bool inited = false;
- if (not inited) {
+ if (static bool inited = false; not inited) {
inited = true;
xbt_log_init(argc, argv);
aid_t get_pid()
{
- auto* self = simgrid::kernel::actor::ActorImpl::self();
+ const auto* self = simgrid::kernel::actor::ActorImpl::self();
return self ? self->get_pid() : 0;
}
const char* get_cname()
{
- auto* self = simgrid::kernel::actor::ActorImpl::self();
+ const auto* self = simgrid::kernel::actor::ActorImpl::self();
return self ? self->get_cname() : nullptr;
}
intrusive_ptr_release(static_cast<sg4::Mutex*>(mutex->mutex));
return 0;
}
-int sthread_sem_init(sthread_sem_t* sem, int pshared, unsigned int value)
+int sthread_sem_init(sthread_sem_t* sem, int /*pshared*/, unsigned int value)
{
auto s = sg4::Semaphore::create(value);
intrusive_ptr_add_ref(s.get());
}
int sthread_sem_timedwait(sthread_sem_t* sem, const struct timespec* abs_timeout)
{
- if (static_cast<sg4::Semaphore*>(sem->sem)->acquire_timeout(abs_timeout->tv_sec +
+ if (static_cast<sg4::Semaphore*>(sem->sem)->acquire_timeout(static_cast<double>(abs_timeout->tv_sec) +
static_cast<double>(abs_timeout->tv_nsec) / 1E9)) {
errno = ETIMEDOUT;
return -1;