Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/clib/cfathread.h

    rd971c8d r038110a  
    1414//
    1515
     16#include "stddef.h"
     17#include "invoke.h"
     18
    1619#if defined(__cforall) || defined(__cplusplus)
    1720extern "C" {
    1821#endif
    19         #include <asm/types.h>
    20         #include <errno.h>
    21         #include <unistd.h>
    22 
     22        //--------------------
     23        // Basic types
     24        struct cfathread_CRunner_t;
     25        typedef struct cfathread_CRunner_t * cfathread_t;
    2326
    2427        //--------------------
    25         // Basic types
    26 
    27         typedef struct cluster * cfathread_cluster_t;
    28 
    29         int cfathread_cluster_create(cfathread_cluster_t * cluster);
    30         cfathread_cluster_t cfathread_cluster_self(void);
    31         int cfathread_cluster_print_stats(cfathread_cluster_t cluster);
    32         int cfathread_cluster_add_worker(cfathread_cluster_t cluster, pthread_t* tid, void (*init_routine) (void *), void * arg);
    33         int cfathread_cluster_pause (cfathread_cluster_t cluster);
    34         int cfathread_cluster_resume(cfathread_cluster_t cluster);
    35 
    36         //--------------------
    37         // thread attribute
    38         typedef struct cfathread_attr {
    39                 cfathread_cluster_t cl;
    40         } cfathread_attr_t;
    41 
    42         int cfathread_attr_init(cfathread_attr_t * attr) __attribute__((nonnull (1)));
    43         static inline int cfathread_attr_destroy(cfathread_attr_t * attr) __attribute__((nonnull (1)));
    44         static inline int cfathread_attr_destroy(cfathread_attr_t * attr) { return 0; }
    45         static inline int cfathread_attr_setbackground(cfathread_attr_t * attr, int background) __attribute__((nonnull (1)));
    46         static inline int cfathread_attr_setbackground(cfathread_attr_t * attr, int background) { return 0; }
    47         static inline int cfathread_attr_setcluster(cfathread_attr_t * attr, cfathread_cluster_t cl) __attribute__((nonnull (1)));
    48         static inline int cfathread_attr_setcluster(cfathread_attr_t * attr, cfathread_cluster_t cl) { attr->cl = cl; return 0; }
    49 
    50         //--------------------
    51         // thread type
    52         struct cfathread_object;
    53         typedef struct cfathread_object * cfathread_t;
    54 
    55         int cfathread_create( cfathread_t * h, const cfathread_attr_t * a, void *(*main)( void * ), void * arg ) __attribute__((nonnull (1)));
    56         int cfathread_join( cfathread_t, void ** retval );
    57 
    58         int cfathread_get_errno(void);
    59         cfathread_t cfathread_self(void);
    60 
    61         int cfathread_usleep(useconds_t usecs);
    62         int cfathread_sleep(unsigned int secs);
     28        // Basic thread support
     29        cfathread_t cfathread_create( void (*main)( cfathread_t ) );
     30        void cfathread_join( cfathread_t );
    6331
    6432        void cfathread_park( void );
     
    6735
    6836        //--------------------
    69         // mutex and condition
    70         struct timespec;
     37        // Basic kernel features
     38        void cfathread_setproccnt( int );
    7139
    72         typedef struct cfathread_mutex_attr {
    73         } cfathread_mutexattr_t;
    74         typedef struct cfathread_mutex * cfathread_mutex_t;
    75         int cfathread_mutex_init(cfathread_mutex_t *restrict mut, const cfathread_mutexattr_t *restrict attr) __attribute__((nonnull (1)));
    76         int cfathread_mutex_destroy(cfathread_mutex_t *mut) __attribute__((nonnull (1)));
    77         int cfathread_mutex_lock(cfathread_mutex_t *mut) __attribute__((nonnull (1)));
    78         int cfathread_mutex_trylock(cfathread_mutex_t *mut) __attribute__((nonnull (1)));
    79         int cfathread_mutex_unlock(cfathread_mutex_t *mut) __attribute__((nonnull (1)));
    80 
    81         typedef struct cfathread_cond_attr {
    82         } cfathread_condattr_t;
    83         typedef struct cfathread_condition * cfathread_cond_t;
    84         int cfathread_cond_init(cfathread_cond_t *restrict cond, const cfathread_condattr_t *restrict attr) __attribute__((nonnull (1)));
    85         int cfathread_cond_wait(cfathread_cond_t *restrict cond, cfathread_mutex_t *restrict mut) __attribute__((nonnull (1,2)));
    86         int cfathread_cond_timedwait(cfathread_cond_t *restrict cond, cfathread_mutex_t *restrict mut, const struct timespec *restrict abstime) __attribute__((nonnull (1,2,3)));
    87         int cfathread_cond_signal(cfathread_cond_t *cond) __attribute__((nonnull (1)));
    88 
    89         //--------------------
    90         // IO operations
    91         struct sockaddr;
    92         struct msghdr;
    93         int cfathread_socket(int domain, int type, int protocol);
    94         int cfathread_bind(int socket, const struct sockaddr *address, socklen_t address_len);
    95         int cfathread_listen(int socket, int backlog);
    96         int cfathread_accept(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len);
    97         int cfathread_connect(int socket, const struct sockaddr *address, socklen_t address_len);
    98         int cfathread_dup(int fildes);
    99         int cfathread_close(int fildes);
    100         ssize_t cfathread_sendmsg(int socket, const struct msghdr *message, int flags);
    101         ssize_t cfathread_write(int fildes, const void *buf, size_t nbyte);
    102         ssize_t cfathread_recvfrom(int socket, void *restrict buffer, size_t length, int flags, struct sockaddr *restrict address, socklen_t *restrict address_len);
    103         ssize_t cfathread_read(int fildes, void *buf, size_t nbyte);
    10440
    10541#if defined(__cforall) || defined(__cplusplus)
Note: See TracChangeset for help on using the changeset viewer.