1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #include <stdio.h>
- #include <stdlib.h>
- #include "pthread.h"
- #include "implement.h"
- int
- pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr)
- {
- int result = 0;
- pthread_mutex_t mx;
- if (mutex == NULL)
- {
- return EINVAL;
- }
- mx = (pthread_mutex_t) calloc (1, sizeof (*mx));
- if (mx == NULL)
- {
- result = ENOMEM;
- }
- else
- {
- mx->lock_idx = 0;
- mx->recursive_count = 0;
- mx->kind = (attr == NULL || *attr == NULL
- ? PTHREAD_MUTEX_DEFAULT : (*attr)->kind);
- mx->ownerThread.p = NULL;
- pte_osSemaphoreCreate(0,&mx->handle);
- }
- *mutex = mx;
- return (result);
- }
|