string.h,signal.h,fcntl.h ,terrnios.h,timer.h,sigcontext.h,stat.h

本文详细介绍了C语言中几个关键头文件的功能与用途,包括string.h中的字符串操作函数,signal.h中的信号处理,fcntl.h中的文件描述符操作,以及terrniios.h、timer.h等头文件的相关功能。

string.h主要定义了很多字符串操作函数

signal.h主要定义标准信号名,跟一些信号函数。

fcntl.h 主要针对文件系统,包含了Creat,open等系统调用, fcntl()用来操作文件描述词的一些特性,

其中有个重要的结构体。

 

struct flcok
{
short int l_type; /* 锁定的状态*/
short int l_whence;/*决定l_start位置*/
off_t l_start; /*锁定区域的开头位置*/
off_t l_len; /*锁定区域的大小*/
pid_t l_pid; /*锁定动作的进程*/
};
l_type 有三种状态:
F_RDLCK 建立一个供读取用的锁定
F_WRLCK 建立一个供写入用的锁定
F_UNLCK 删除之前建立的锁定
l_whence 也有三种方式:
SEEK_SET 以文件开头为锁定的起始位置。
SEEK_CUR 以目前文件读写位置为锁定的起始位置
SEEK_END 以文件结尾为锁定的起始位置。
terrnios.h
操作系统控制台跟终端接口是很复杂的。所以要有个标准,让不同硬件能跟操作系统和用户交互。
这个文件就干这些事情。它定义了控制终端类型的I/O 设备要用到的常量,宏和函数原型,
最重要的是terrnios结构,包含的内容有:标识各种操作模式的标志位,设置输入输出频率的变量和
放置特殊字符的数组。这个文件定义的东西多数是POSIX需要的。但后面它也定义了一些MINIX自己扩展的东西,
比如定义57600或以上的波特率。 
timer.h提供一些watchdog时间管理功能。
sigcontext.h
用于内核的内存管理器。定义一些用来在信号处理前后保存和恢复系统操作的结构。 

stat.h
定义了stat()和fstat()函数返回的结构,用来操作文件的。主要用于内存管理和文件系统上。
定义了chmod, fstat, mkdir, mkfifo, stat, umask这些函数的原型。 

 

#include <libubox/uloop.h> #include <libubox/ustream.h> #include <libubox/utils.h> #include <libubus.h> #include <json/json.h> #include <libubox/blobmsg_json.h> #include <time.h> #include <sys/time.h> #include <signal.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> //malloc free #include <string.h> //memset #include <arpa/inet.h> //ntohl #include <stdio.h> #include <dirent.h> #include <mntent.h> #include <sys/statfs.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <curl/curl.h> #include <pthread.h> #include "nvrwork_ubus.h" #include "tp_type.h" #include <termios.h> #include <linux/input.h> #include <linux/uinput.h> #include <errno.h> #include <linux/hdreg.h> #include <linux/types.h> #include <fcntl.h> #include <sys/ioctl.h> #include"trace_alloc.h" static struct ubus_context * media_ctx = NULL; static const char * wm_path; typedef struct _TEST_STRUCT{ int val; }TEST_STRUCT; static int nvrwork_trigger_mem_leak(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { int *ptr = (int *)malloc(sizeof(int) * 100); memset(ptr, 1, (sizeof(int) * 100)); printf("Memory leak callback.\n"); return OK; } static int nvrwork_trigger_access_nullptr(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { TEST_STRUCT *ts = NULL; ts->val = 1; int value = ts->val; printf("%d\n", value); printf("Access nullptr callback.\n"); return OK; } static int nvrwork_trigger_trace_alloc(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { trace_alloc_debug(); return OK; } static struct ubus_method nvrwork_methods[] = { {.name = "mem_leak", .handler = nvrwork_trigger_mem_leak}, {.name = "access_nullptr", .handler = nvrwork_trigger_access_nullptr}, {.name = "trace_alloc", .handler = nvrwork_trigger_trace_alloc}, }; static struct ubus_object_type nvrwork_obj_type = UBUS_OBJECT_TYPE("nvrwork", nvrwork_methods); static struct ubus_object nvrwork_obj = { .name = "nvrwork", .type = &nvrwork_obj_type, .methods = nvrwork_methods, .n_methods = ARRAY_SIZE(nvrwork_methods), }; static void ubus_add_fd(void) { ubus_add_uloop(media_ctx); #ifdef FD_CLOEXEC fcntl(media_ctx->sock.fd, F_SETFD, fcntl(media_ctx->sock.fd, F_GETFD) | FD_CLOEXEC); #endif } static void ubus_reconn_timer(struct uloop_timeout *timeout) { static struct uloop_timeout retry = { .cb = ubus_reconn_timer, }; int t = 2; if (ubus_reconnect(media_ctx, wm_path) != 0) { uloop_timeout_set(&retry, t * 1000); return; } ubus_add_fd(); } static void ubus_connection_lost(struct ubus_context *ctx) { ubus_reconn_timer(NULL); } int nvrwork_ubus_init(const char *path) { uloop_init(); wm_path = path; media_ctx = ubus_connect(NULL); if (!media_ctx) { printf("ubus connect failed\n"); return ERROR; } printf("connected as %08x\n", media_ctx->local_id); media_ctx->connection_lost = ubus_connection_lost; ubus_add_fd(); if (ubus_add_object(media_ctx, &nvrwork_obj) != 0) { printf("ubus add obj failed\n"); return ERROR; } return OK; } void nvrwork_ubus_done(void) { if (media_ctx) ubus_free(media_ctx); } int real_main(void * arg) { char * path = (char *)arg; if (ERROR == nvrwork_ubus_init(path)) { printf("ubus connect failed!\n"); return ERROR; } trace_alloc_set_threshold(100); uloop_run(); nvrwork_ubus_done(); return OK; } int main(int argc, char * argv[]) { real_main(NULL); return OK; } 分析一下这个代码 我要写一个新的模块 要模仿一下这个模块代码
最新发布
09-09
sr/include/time.h:371:27: error: unknown type name ‘timer_t’ extern int timer_settime (timer_t __timerid, int __flags, ^ /usr/include/time.h:376:27: error: unknown type name ‘timer_t’ extern int timer_gettime (timer_t __timerid, struct itimerspec *__value) ^ /usr/include/time.h:380:30: error: unknown type name ‘timer_t’ extern int timer_getoverrun (timer_t __timerid) __THROW; ^ In file included from /usr/include/pthread.h:26:0, from multi_threaded.c:2: /usr/include/bits/pthreadtypes.h:60:27: error: storage class specified for parameter ‘pthread_t’ typedef unsigned long int pthread_t; ^ /usr/include/bits/pthreadtypes.h:69:30: error: storage class specified for parameter ‘pthread_attr_t’ typedef union pthread_attr_t pthread_attr_t; ^ /usr/include/bits/pthreadtypes.h:79:3: error: storage class specified for parameter ‘__pthread_list_t’ } __pthread_list_t; ^ /usr/include/bits/pthreadtypes.h:106:5: error: expected specifier-qualifier-list before ‘__pthread_list_t’ __pthread_list_t __list; ^ /usr/include/bits/pthreadtypes.h:128:3: error: storage class specified for parameter ‘pthread_mutex_t’ } pthread_mutex_t; ^ /usr/include/bits/pthreadtypes.h:134:3: error: storage class specified for parameter ‘pthread_mutexattr_t’ } pthread_mutexattr_t; ^ /usr/include/bits/pthreadtypes.h:154:3: error: storage class specified for parameter ‘pthread_cond_t’ } pthread_cond_t; ^ /usr/include/bits/pthreadtypes.h:160:3: error: storage class specified for parameter ‘pthread_condattr_t’ } pthread_condattr_t; ^ /usr/include/bits/pthreadtypes.h:164:22: error: storage class specified for parameter ‘pthread_key_t’ typedef unsigned int pthread_key_t; ^ /usr/include/bits/pthreadtypes.h:168:13: error: storage class specified for parameter ‘pthread_once_t’ typedef int pthread_once_t; ^ /usr/include/bits/pthreadtypes.h:214:3: error: storage class specified for parameter ‘pthread_rwlock_t’ } pthread_rwlock_t; ^ /usr/include/bits/pthreadtypes.h:220:3: error: storage class specified for parameter ‘pthread_rwlockattr_t’ } pthread_rwlockattr_t; ^ /usr/include/bits/pthreadtypes.h:226:22: error: storage class specified for parameter ‘pthread_spinlock_t’ typedef volatile int pthread_spinlock_t; ^ /usr/include/bits/pthreadtypes.h:235:3: error: storage class specified for parameter ‘pthread_barrier_t’ } pthread_barrier_t; ^ /usr/include/bits/pthreadtypes.h:241:3: error: storage class specified for parameter ‘pthread_barrierattr_t’ } pthread_barrierattr_t; ^ In file included from /usr/include/pthread.h:27:0, from multi_threaded.c:2: /usr/include/bits/setjmp.h:31:18: error: storage class specified for parameter ‘__jmp_buf’ typedef long int __jmp_buf[8]; ^ In file included from multi_threaded.c:2:0: /usr/include/pthread.h:235:28: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ extern int pthread_create (pthread_t *__restrict __newthread, ^ /usr/include/pthread.h:236:28: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token const pthread_attr_t *__restrict __attr, ^ /usr/include/pthread.h:244:13: error: storage class specified for parameter ‘pthread_exit’ extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__)); ^ /usr/include/pthread.h:252:26: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ extern int pthread_join (pthread_t __th, void **__thread_return); ^ /usr/include/pthread.h:273:28: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ extern int pthread_detach (pthread_t __th) __THROW; ^ /usr/include/pthread.h:277:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pthread_self’ extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__)); ^ /usr/include/pthread.h:280:27: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) ^ /usr/include/pthread.h:280:48: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) ^ /usr/include/pthread.h:289:31: error: expected declaration specifiers or ‘...’ before ‘pthread_attr_t’ extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1)); ^ /usr/include/pthread.h:292:34: error: expected declaration specifiers or ‘...’ before ‘pthread_attr_t’ extern int pthread_attr_destroy (pthread_attr_t *__attr) ^ /usr/include/pthread.h:296:62: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr, ^ /usr/include/pthread.h:301:41: error: expected declaration specifiers or ‘...’ before ‘pthread_attr_t’ extern int pthread_attr_setdetachstate (pthread_attr_t *__attr, ^ /usr/include/pthread.h:307:60: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_attr_getguardsize (const pthread_attr_t *__attr, ^ /usr/include/pthread.h:312:39: error: expected declaration specifiers or ‘...’ before ‘pthread_attr_t’ extern int pthread_attr_setguardsize (pthread_attr_t *__attr, ^ /usr/include/pthread.h:313:11: error: expected declaration specifiers or ‘...’ before ‘size_t’ size_t __guardsize) ^ /usr/include/pthread.h:318:61: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr, ^ /usr/include/pthread.h:323:40: error: expected declaration specifiers or ‘...’ before ‘pthread_attr_t’ extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr, ^ /usr/include/pthread.h:328:62: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict ^ /usr/include/pthread.h:333:41: error: expected declaration specifiers or ‘...’ before ‘pthread_attr_t’ extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy) ^ /usr/include/pthread.h:337:63: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict ^ /usr/include/pthread.h:342:42: error: expected declaration specifiers or ‘...’ before ‘pthread_attr_t’ extern int pthread_attr_setinheritsched (pthread_attr_t *__attr, ^ /usr/include/pthread.h:348:56: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr, ^ /usr/include/pthread.h:353:35: error: expected declaration specifiers or ‘...’ before ‘pthread_attr_t’ extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope) ^ /usr/include/pthread.h:357:60: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict ^ /usr/include/pthread.h:365:39: error: expected declaration specifiers or ‘...’ before ‘pthread_attr_t’ extern int pthread_attr_setstackaddr (pthread_attr_t *__attr, ^ /usr/include/pthread.h:370:60: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict ^ /usr/include/pthread.h:377:39: error: expected declaration specifiers or ‘...’ before ‘pthread_attr_t’ extern int pthread_attr_setstacksize (pthread_attr_t *__attr, ^ /usr/include/pthread.h:378:11: error: expected declaration specifiers or ‘...’ before ‘size_t’ size_t __stacksize) ^ /usr/include/pthread.h:383:56: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr, ^ /usr/include/pthread.h:391:35: error: expected declaration specifiers or ‘...’ before ‘pthread_attr_t’ extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr, ^ /usr/include/pthread.h:392:7: error: expected declaration specifiers or ‘...’ before ‘size_t’ size_t __stacksize) __THROW __nonnull ((1)); ^ /usr/include/pthread.h:423:35: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ extern int pthread_setschedparam (pthread_t __target_thread, int __policy, ^ /usr/include/pthread.h:428:35: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ extern int pthread_getschedparam (pthread_t __target_thread, ^ /usr/include/pthread.h:434:34: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ extern int pthread_setschedprio (pthread_t __target_thread, int __prio) ^ /usr/include/pthread.h:488:26: error: expected declaration specifiers or ‘...’ before ‘pthread_once_t’ extern int pthread_once (pthread_once_t *__once_control, ^ /usr/include/pthread.h:500:12: error: storage class specified for parameter ‘pthread_setcancelstate’ extern int pthread_setcancelstate (int __state, int *__oldstate); ^ /usr/include/pthread.h:504:12: error: storage class specified for parameter ‘pthread_setcanceltype’ extern int pthread_setcanceltype (int __type, int *__oldtype); ^ /usr/include/pthread.h:507:28: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ extern int pthread_cancel (pthread_t __th); ^ /usr/include/pthread.h:512:13: error: storage class specified for parameter ‘pthread_testcancel’ extern void pthread_testcancel (void); ^ /usr/include/pthread.h:521:5: error: expected specifier-qualifier-list before ‘__jmp_buf’ __jmp_buf __cancel_jmp_buf; ^ /usr/include/pthread.h:525:3: error: storage class specified for parameter ‘__pthread_unwind_buf_t’ } __pthread_unwind_buf_t __attribute__ ((__aligned__)); ^ /usr/include/pthread.h:525:3: error: alignment may not be specified for ‘__pthread_unwind_buf_t’ /usr/include/pthread.h:674:40: error: expected declaration specifiers or ‘...’ before ‘__pthread_unwind_buf_t’ extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf) ^ /usr/include/pthread.h:686:42: error: expected declaration specifiers or ‘...’ before ‘__pthread_unwind_buf_t’ extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf) ^ /usr/include/pthread.h:727:36: error: expected declaration specifiers or ‘...’ before ‘__pthread_unwind_buf_t’ extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf) ^ /usr/include/pthread.h:737:12: error: storage class specified for parameter ‘__sigsetjmp’ extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL; ^ /usr/include/pthread.h:743:32: error: expected declaration specifiers or ‘...’ before ‘pthread_mutex_t’ extern int pthread_mutex_init (pthread_mutex_t *__mutex, ^ /usr/include/pthread.h:744:37: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token const pthread_mutexattr_t *__mutexattr) ^ /usr/include/pthread.h:748:35: error: expected declaration specifiers or ‘...’ before ‘pthread_mutex_t’ extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) ^ /usr/include/pthread.h:752:35: error: expected declaration specifiers or ‘...’ before ‘pthread_mutex_t’ extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) ^ /usr/include/pthread.h:756:32: error: expected declaration specifiers or ‘...’ before ‘pthread_mutex_t’ extern int pthread_mutex_lock (pthread_mutex_t *__mutex) ^ /usr/include/pthread.h:761:37: error: expected declaration specifiers or ‘...’ before ‘pthread_mutex_t’ extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex, ^ /usr/include/pthread.h:767:34: error: expected declaration specifiers or ‘...’ before ‘pthread_mutex_t’ extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) ^ /usr/include/pthread.h:772:64: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_mutex_getprioceiling (const pthread_mutex_t * ^ /usr/include/pthread.h:779:42: error: expected declaration specifiers or ‘...’ before ‘pthread_mutex_t’ extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex, ^ /usr/include/pthread.h:787:38: error: expected declaration specifiers or ‘...’ before ‘pthread_mutex_t’ extern int pthread_mutex_consistent (pthread_mutex_t *__mutex) ^ /usr/include/pthread.h:800:36: error: expected declaration specifiers or ‘...’ before ‘pthread_mutexattr_t’ extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) ^ /usr/include/pthread.h:804:39: error: expected declaration specifiers or ‘...’ before ‘pthread_mutexattr_t’ extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) ^ /usr/include/pthread.h:808:68: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t * ^ /usr/include/pthread.h:814:42: error: expected declaration specifiers or ‘...’ before ‘pthread_mutexattr_t’ extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr, ^ /usr/include/pthread.h:820:65: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict ^ /usr/include/pthread.h:827:39: error: expected declaration specifiers or ‘...’ before ‘pthread_mutexattr_t’ extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) ^ /usr/include/pthread.h:832:69: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t * ^ /usr/include/pthread.h:839:43: error: expected declaration specifiers or ‘...’ before ‘pthread_mutexattr_t’ extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr, ^ /usr/include/pthread.h:844:72: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t * ^ /usr/include/pthread.h:850:46: error: expected declaration specifiers or ‘...’ before ‘pthread_mutexattr_t’ extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr, ^ /usr/include/pthread.h:856:67: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr, ^ /usr/include/pthread.h:866:41: error: expected declaration specifiers or ‘...’ before ‘pthread_mutexattr_t’ extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr, ^ /usr/include/pthread.h:882:33: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlock_t’ extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock, ^ /usr/include/pthread.h:883:32: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token const pthread_rwlockattr_t *__restrict ^ /usr/include/pthread.h:887:36: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlock_t’ extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) ^ /usr/include/pthread.h:891:35: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlock_t’ extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) ^ /usr/include/pthread.h:895:38: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlock_t’ extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) ^ /usr/include/pthread.h:900:40: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlock_t’ extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock, ^ /usr/include/pthread.h:906:35: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlock_t’ extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) ^ /usr/include/pthread.h:910:38: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlock_t’ extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) ^ /usr/include/pthread.h:915:40: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlock_t’ extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock, ^ /usr/include/pthread.h:921:35: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlock_t’ extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) ^ /usr/include/pthread.h:928:37: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlockattr_t’ extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) ^ /usr/include/pthread.h:932:40: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlockattr_t’ extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) ^ /usr/include/pthread.h:936:70: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * ^ /usr/include/pthread.h:942:43: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlockattr_t’ extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr, ^ /usr/include/pthread.h:947:70: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t * ^ /usr/include/pthread.h:953:43: error: expected declaration specifiers or ‘...’ before ‘pthread_rwlockattr_t’ extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr, ^ /usr/include/pthread.h:962:31: error: expected declaration specifiers or ‘...’ before ‘pthread_cond_t’ extern int pthread_cond_init (pthread_cond_t *__restrict __cond, ^ /usr/include/pthread.h:963:35: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token const pthread_condattr_t *__restrict __cond_attr) ^ /usr/include/pthread.h:967:34: error: expected declaration specifiers or ‘...’ before ‘pthread_cond_t’ extern int pthread_cond_destroy (pthread_cond_t *__cond) ^ /usr/include/pthread.h:971:33: error: expected declaration specifiers or ‘...’ before ‘pthread_cond_t’ extern int pthread_cond_signal (pthread_cond_t *__cond) ^ /usr/include/pthread.h:975:36: error: expected declaration specifiers or ‘...’ before ‘pthread_cond_t’ extern int pthread_cond_broadcast (pthread_cond_t *__cond) ^ /usr/include/pthread.h:983:31: error: expected declaration specifiers or ‘...’ before ‘pthread_cond_t’ extern int pthread_cond_wait (pthread_cond_t *__restrict __cond, ^ /usr/include/pthread.h:984:10: error: expected declaration specifiers or ‘...’ before ‘pthread_mutex_t’ pthread_mutex_t *__restrict __mutex) ^ /usr/include/pthread.h:994:36: error: expected declaration specifiers or ‘...’ before ‘pthread_cond_t’ extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond, ^ /usr/include/pthread.h:995:8: error: expected declaration specifiers or ‘...’ before ‘pthread_mutex_t’ pthread_mutex_t *__restrict __mutex, ^ /usr/include/pthread.h:1002:35: error: expected declaration specifiers or ‘...’ before ‘pthread_condattr_t’ extern int pthread_condattr_init (pthread_condattr_t *__attr) ^ /usr/include/pthread.h:1006:38: error: expected declaration specifiers or ‘...’ before ‘pthread_condattr_t’ extern int pthread_condattr_destroy (pthread_condattr_t *__attr) ^ /usr/include/pthread.h:1010:66: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_condattr_getpshared (const pthread_condattr_t * ^ /usr/include/pthread.h:1016:41: error: expected declaration specifiers or ‘...’ before ‘pthread_condattr_t’ extern int pthread_condattr_setpshared (pthread_condattr_t *__attr, ^ /usr/include/pthread.h:1021:64: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_condattr_getclock (const pthread_condattr_t * ^ /usr/include/pthread.h:1027:39: error: expected declaration specifiers or ‘...’ before ‘pthread_condattr_t’ extern int pthread_condattr_setclock (pthread_condattr_t *__attr, ^ /usr/include/pthread.h:1028:11: error: expected declaration specifiers or ‘...’ before ‘__clockid_t’ __clockid_t __clock_id) ^ /usr/include/pthread.h:1038:31: error: expected declaration specifiers or ‘...’ before ‘pthread_spinlock_t’ extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared) ^ /usr/include/pthread.h:1042:34: error: expected declaration specifiers or ‘...’ before ‘pthread_spinlock_t’ extern int pthread_spin_destroy (pthread_spinlock_t *__lock) ^ /usr/include/pthread.h:1046:31: error: expected declaration specifiers or ‘...’ before ‘pthread_spinlock_t’ extern int pthread_spin_lock (pthread_spinlock_t *__lock) ^ /usr/include/pthread.h:1050:34: error: expected declaration specifiers or ‘...’ before ‘pthread_spinlock_t’ extern int pthread_spin_trylock (pthread_spinlock_t *__lock) ^ /usr/include/pthread.h:1054:33: error: expected declaration specifiers or ‘...’ before ‘pthread_spinlock_t’ extern int pthread_spin_unlock (pthread_spinlock_t *__lock) ^ /usr/include/pthread.h:1062:34: error: expected declaration specifiers or ‘...’ before ‘pthread_barrier_t’ extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier, ^ /usr/include/pthread.h:1063:34: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token const pthread_barrierattr_t *__restrict ^ /usr/include/pthread.h:1068:37: error: expected declaration specifiers or ‘...’ before ‘pthread_barrier_t’ extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) ^ /usr/include/pthread.h:1072:34: error: expected declaration specifiers or ‘...’ before ‘pthread_barrier_t’ extern int pthread_barrier_wait (pthread_barrier_t *__barrier) ^ /usr/include/pthread.h:1077:38: error: expected declaration specifiers or ‘...’ before ‘pthread_barrierattr_t’ extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) ^ /usr/include/pthread.h:1081:41: error: expected declaration specifiers or ‘...’ before ‘pthread_barrierattr_t’ extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) ^ /usr/include/pthread.h:1085:72: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t * ^ /usr/include/pthread.h:1091:44: error: expected declaration specifiers or ‘...’ before ‘pthread_barrierattr_t’ extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr, ^ /usr/include/pthread.h:1105:32: error: expected declaration specifiers or ‘...’ before ‘pthread_key_t’ extern int pthread_key_create (pthread_key_t *__key, ^ /usr/include/pthread.h:1110:32: error: expected declaration specifiers or ‘...’ before ‘pthread_key_t’ extern int pthread_key_delete (pthread_key_t __key) __THROW; ^ /usr/include/pthread.h:1113:35: error: expected declaration specifiers or ‘...’ before ‘pthread_key_t’ extern void *pthread_getspecific (pthread_key_t __key) __THROW; ^ /usr/include/pthread.h:1116:33: error: expected declaration specifiers or ‘...’ before ‘pthread_key_t’ extern int pthread_setspecific (pthread_key_t __key, ^ /usr/include/pthread.h:1122:35: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ extern int pthread_getcpuclockid (pthread_t __thread_id, ^ /usr/include/pthread.h:1123:7: error: expected declaration specifiers or ‘...’ before ‘__clockid_t’ __clockid_t *__clock_id) ^ /usr/include/pthread.h:1139:12: error: storage class specified for parameter ‘pthread_atfork’ extern int pthread_atfork (void (*__prepare) (void), ^ multi_threaded.c:5:21: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token int create_socket() { ^ multi_threaded.c:18:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token void bind_socket(int sockfd) { ^ multi_threaded.c:33:48: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token const char* get_content_type(const char* path) { ^ multi_threaded.c:50:36: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token int is_path_safe(const char* path) { ^ multi_threaded.c:55:40: error: unknown type name ‘http_status_t’ void send_http_response(int client_fd, http_status_t status, ^ multi_threaded.c:56:51: error: unknown type name ‘off_t’ const char* content_type, off_t content_length) { ^ multi_threaded.c:79:41: error: unknown type name ‘http_status_t’ void send_error_response(int client_fd, http_status_t status) { ^ multi_threaded.c:111:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token void* handle_client(void* arg) { ^ multi_threaded.c:182:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token int main() { ^ In file included from web_server.h:3:0, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from web_server.h:2, from multi_threaded.c:1: /usr/include/signal.h:403:12: error: old-style parameter declarations in prototyped function definition extern int __libc_current_sigrtmin (void) __THROW; ^ multi_threaded.c:218:1: error: expected ‘{’ at end of input } ^ multi_threaded.c:218:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ makefile:13: recipe for target 'threaded_server' failed make: *** [threaded_server] Error 1 出现一大堆报错
08-08
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值