mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-13 16:35:35 +08:00
Merge branch 'gitee-master' into gitlab-upstream
This commit is contained in:
commit
8c7a7fb20d
16
build_by_cosmocc
Executable file
16
build_by_cosmocc
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
export ENV_CC=cosmocc
|
||||
export ENV_CPP=cosmoc++
|
||||
|
||||
cd lib_acl; make -j 4;
|
||||
cd samples; make;
|
||||
cd ../..
|
||||
|
||||
cd lib_protocol; make -j 4;
|
||||
cd samples; make;
|
||||
cd ../..
|
||||
|
||||
cd lib_acl_cpp; make -j 10
|
||||
cd samples; make;
|
||||
cd ../..
|
||||
|
@ -95,6 +95,14 @@ ifeq ($(findstring clang++, $(CC)), clang)
|
||||
-Wno-invalid-offsetof
|
||||
endif
|
||||
|
||||
ifeq ($(findstring cosmocc, $(CC)), cosmocc)
|
||||
CFLAGS += -DCOSMOCC
|
||||
CFLAGS += -Wno-implicit-fallthrough
|
||||
CFLAGS += -DLINUX2
|
||||
AR = cosmoar
|
||||
|
||||
endif
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
UNIXTYPE = FREEBSD
|
||||
|
@ -19,8 +19,10 @@ extern "C" {
|
||||
|
||||
# if defined(ACL_FREEBSD) || defined(ACL_SUNOS5) || defined(ACL_MACOSX) || defined(ALPINE) || defined(MINGW)
|
||||
# define ACL_PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE
|
||||
# else
|
||||
# elif defined(PTHREAD_MUTEX_RECURSIVE_NP)
|
||||
# define ACL_PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
|
||||
# else
|
||||
# define ACL_PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE
|
||||
# endif
|
||||
|
||||
typedef pthread_t acl_pthread_t;
|
||||
|
@ -49,6 +49,13 @@ ifeq ($(findstring gcc, $(CC)), clang++)
|
||||
-Wno-invalid-offsetof
|
||||
endif
|
||||
|
||||
ifeq ($(findstring cosmocc, $(CC)), cosmocc)
|
||||
CFLAGS += -DCOSMOCC
|
||||
CFLAGS += -Wno-implicit-fallthrough
|
||||
CFLAGS += -DLINUX2
|
||||
|
||||
endif
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
CFLAGS += -DFREEBSD
|
||||
|
@ -41,6 +41,14 @@ ifeq ($(findstring clang++, $(CC)), clang++)
|
||||
-Wno-invalid-offsetof
|
||||
endif
|
||||
|
||||
ifeq ($(findstring cosmoc+, $(CC)), cosmoc+)
|
||||
CFLAGS += -DCOSMOCC
|
||||
CFLAGS += -DLINUX2
|
||||
CFLAGS += -Wno-implicit-fallthrough
|
||||
CFLAGS += -fexceptions
|
||||
|
||||
endif
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
CFLAGS += -DFREEBSD -pedantic
|
||||
|
@ -1,4 +1,4 @@
|
||||
CC = $(MY_ENV_CC)
|
||||
CC = $(ENV_CC)
|
||||
#CC = gcc
|
||||
|
||||
CFLAGS = -c -g -W -Wall -Wcast-qual -Wcast-align \
|
||||
|
0
lib_acl/samples/dbuf/valgrind.sh
Normal file → Executable file
0
lib_acl/samples/dbuf/valgrind.sh
Normal file → Executable file
@ -24,7 +24,12 @@ extern "C" {
|
||||
*/
|
||||
#if (ACL_EVENTS_KERNEL_STYLE == ACL_EVENTS_STYLE_EPOLL)
|
||||
#include <stdint.h>
|
||||
#include <sys/epoll.h>
|
||||
#ifdef COSMOCC
|
||||
# include <libc/sysv/consts/epoll.h>
|
||||
# include <libc/sock/epoll.h>
|
||||
#else
|
||||
# include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#define EVENT_NAME "epoll"
|
||||
|
||||
|
@ -33,7 +33,13 @@
|
||||
#ifdef ACL_EVENTS_KERNEL_STYLE
|
||||
#if (ACL_EVENTS_KERNEL_STYLE == ACL_EVENTS_STYLE_EPOLL)
|
||||
|
||||
#include <sys/epoll.h>
|
||||
#ifdef COSMOCC
|
||||
# include <libc/sysv/consts/epoll.h>
|
||||
# include <libc/sock/epoll.h>
|
||||
#else
|
||||
# include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#include "events_fdtable.h"
|
||||
#include "events.h"
|
||||
|
||||
|
@ -7,6 +7,9 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef COSMOCC
|
||||
|
||||
#include <linux/netlink.h>
|
||||
//#include <linux/route.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
@ -117,5 +120,6 @@ void netlink_monitor(ACL_EVENT *event, monitor_callback callback, void *ctx)
|
||||
|
||||
acl_event_enable_read(event, stream, 0, netlink_callback, nc);
|
||||
}
|
||||
#endif /* COSMOCC */
|
||||
|
||||
#endif /* ACL_LINUX */
|
||||
|
@ -222,12 +222,14 @@ size_t acl_inet_ntop(const struct sockaddr *sa, char *buf, size_t size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(ACL_UNIX) || (defined(ACL_WINDOWS) && _MSC_VER >= 1600)
|
||||
#if defined(COSMOCC)
|
||||
ifname[0] = 0;
|
||||
#elif defined(ACL_UNIX) || (defined(ACL_WINDOWS) && _MSC_VER >= 1600)
|
||||
ptr = (char*) if_indextoname(in6->sin6_scope_id, ifname);
|
||||
if (ptr == NULL) {
|
||||
ifname[0] = 0;
|
||||
}
|
||||
# else
|
||||
#else
|
||||
ifname[0] = 0;
|
||||
#endif
|
||||
|
||||
@ -323,11 +325,13 @@ size_t acl_inet_pton(int af, const char *src, struct sockaddr *dst)
|
||||
in6->sin6_family = AF_INET6;
|
||||
in6->sin6_port = htons(port);
|
||||
#if defined(ACL_UNIX) || (defined(ACL_WINDOWS) && _MSC_VER >= 1600)
|
||||
# ifndef COSMOCC
|
||||
if (ptr && *ptr && !(in6->sin6_scope_id = if_nametoindex(ptr))) {
|
||||
acl_msg_error("%s(%d): if_nametoindex error %s",
|
||||
__FUNCTION__, __LINE__, acl_last_serror());
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (inet_pton(af, buf, &in6->sin6_addr) == 0) {
|
||||
|
@ -1000,11 +1000,13 @@ static size_t save_addr2rr(int type, const char *src, ACL_RFC1035_RR *rr)
|
||||
in6.sin6_port = htons(0);
|
||||
|
||||
#if defined(ACL_UNIX) || (defined(ACL_WINDOWS) && _MSC_VER >= 1600)
|
||||
# ifndef COSMOCC
|
||||
if (ptr && *ptr && !(in6.sin6_scope_id = if_nametoindex(ptr))) {
|
||||
acl_msg_error("%s(%d): if_nametoindex error %s",
|
||||
__FUNCTION__, __LINE__, acl_last_serror());
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
if (inet_pton(AF_INET6, buf, &in6.sin6_addr) == 0) {
|
||||
acl_msg_error("%s(%d): invalid addr=%s",
|
||||
|
@ -18,6 +18,10 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef COSMOCC
|
||||
#include <libc/calls/syscall-sysv.internal.h>
|
||||
#endif
|
||||
|
||||
/* Utility library. */
|
||||
|
||||
#include "stdlib/acl_msg.h"
|
||||
@ -53,7 +57,12 @@ int acl_fifo_listen(const char *path, int permissions, int block_mode)
|
||||
acl_last_strerror(tbuf, sizeof(tbuf)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef COSMOCC
|
||||
if (sys_mkfifo(path, permissions) < 0) {
|
||||
#else
|
||||
if (mkfifo(path, permissions) < 0) {
|
||||
#endif
|
||||
acl_msg_error("%s: create fifo %s: %s", myname, path,
|
||||
acl_last_strerror(tbuf, sizeof(tbuf)));
|
||||
return -1;
|
||||
|
@ -19,7 +19,7 @@
|
||||
# if defined(ALPINE)
|
||||
# include <sys/eventfd.h>
|
||||
# define HAS_EVENTFD
|
||||
# else
|
||||
# elif !defined(COSMOCC)
|
||||
# include <linux/version.h>
|
||||
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
|
||||
# include <sys/eventfd.h>
|
||||
|
@ -154,8 +154,10 @@ static void init_log_mutex(acl_pthread_mutex_t *lock)
|
||||
n2 = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
# elif defined(MINGW)
|
||||
n2 = 0;
|
||||
# else
|
||||
# elif defined(PTHREAD_MUTEX_RECURSIVE_NP)
|
||||
n2 = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
|
||||
# else
|
||||
n2 = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
# endif
|
||||
thread_mutex_init(lock, !n1 && !n2 ? &attr : NULL);
|
||||
#else
|
||||
|
@ -30,7 +30,7 @@ typedef int (*ACL_VSTREAM_WAITPID_FN) (pid_t, ACL_WAIT_STATUS_T *, int);
|
||||
typedef struct ACL_VSTREAM_POPEN_ARGS {
|
||||
char **argv;
|
||||
char *command;
|
||||
int privileged;
|
||||
int priv;
|
||||
char **env;
|
||||
char **export;
|
||||
char *shell;
|
||||
@ -53,7 +53,7 @@ static void vstream_parse_args(ACL_VSTREAM_POPEN_ARGS *args, va_list ap)
|
||||
*/
|
||||
args->argv = 0;
|
||||
args->command = 0;
|
||||
args->privileged = 0;
|
||||
args->priv = 0;
|
||||
args->env = 0;
|
||||
args->export = 0;
|
||||
args->shell = 0;
|
||||
@ -93,7 +93,7 @@ static void vstream_parse_args(ACL_VSTREAM_POPEN_ARGS *args, va_list ap)
|
||||
break;
|
||||
#ifdef ACL_UNIX
|
||||
case ACL_VSTREAM_POPEN_UID:
|
||||
args->privileged = 1;
|
||||
args->priv = 1;
|
||||
#ifdef MINGW
|
||||
args->uid = (uid_t) va_arg(ap, int);
|
||||
#else
|
||||
@ -101,7 +101,7 @@ static void vstream_parse_args(ACL_VSTREAM_POPEN_ARGS *args, va_list ap)
|
||||
#endif
|
||||
break;
|
||||
case ACL_VSTREAM_POPEN_GID:
|
||||
args->privileged = 1;
|
||||
args->priv = 1;
|
||||
#ifdef MINGW
|
||||
args->gid = (gid_t) va_arg(ap, int);
|
||||
#else
|
||||
@ -122,11 +122,11 @@ static void vstream_parse_args(ACL_VSTREAM_POPEN_ARGS *args, va_list ap)
|
||||
" or ACL_VSTREAM_POPEN_COMMAND", myname);
|
||||
}
|
||||
#ifdef ACL_UNIX
|
||||
if (args->privileged != 0 && args->uid == 0) {
|
||||
acl_msg_panic("%s: privileged uid", myname);
|
||||
if (args->priv != 0 && args->uid == 0) {
|
||||
acl_msg_panic("%s: priv uid", myname);
|
||||
}
|
||||
if (args->privileged != 0 && args->gid == 0) {
|
||||
acl_msg_panic("%s: privileged gid", myname);
|
||||
if (args->priv != 0 && args->gid == 0) {
|
||||
acl_msg_panic("%s: priv gid", myname);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -214,7 +214,7 @@ ACL_VSTREAM *acl_vstream_popen(int flags,...)
|
||||
/*
|
||||
* Don't try to become someone else unless the user specified it.
|
||||
*/
|
||||
if (args.privileged) {
|
||||
if (args.priv) {
|
||||
acl_set_ugid(args.uid, args.gid);
|
||||
}
|
||||
|
||||
|
@ -84,8 +84,10 @@ static ACL_FHANDLE *__fhandle_alloc(size_t size, unsigned int oflags)
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
# elif defined(MINGW) || defined(ALPINE)
|
||||
pthread_mutex_init(&fs->mutex, &attr);
|
||||
# else
|
||||
# elif defined(PTHREAD_MUTEX_RECURSIVE_NP)
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
|
||||
# else
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
# endif
|
||||
pthread_mutex_init(&fs->mutex, &attr);
|
||||
#else
|
||||
@ -430,8 +432,10 @@ void acl_fhandle_init(int cache_size, int debug_section, unsigned int flags)
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
# elif defined(MINGW) || defined(ALPINE)
|
||||
pthread_mutex_init(&__fhandle_mutex, &attr);
|
||||
# else
|
||||
# elif defined(PTHREAD_MUTEX_RECURSIVE_NP)
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
|
||||
# else
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
# endif
|
||||
pthread_mutex_init(&__fhandle_mutex, &attr);
|
||||
#else
|
||||
|
@ -26,7 +26,12 @@
|
||||
|
||||
#include "init/acl_init.h"
|
||||
#include "thread/acl_pthread.h"
|
||||
#ifdef COSMOCC
|
||||
#include <libc/sysv/consts/epoll.h>
|
||||
#include <libc/sock/epoll.h>
|
||||
#else
|
||||
#include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
typedef struct EPOLL_CTX
|
||||
{
|
||||
|
@ -120,13 +120,15 @@ int acl_dbuf_pool_reset(ACL_DBUF_POOL *pool, size_t off)
|
||||
acl_msg_warn("warning: %s(%d) off(%ld) > pool->off(%ld)",
|
||||
__FUNCTION__, __LINE__, (long) off, (long) pool->off);
|
||||
return -1;
|
||||
} else if (off == pool->off)
|
||||
} else if (off == pool->off) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
/* 如果当前内存块有保留内存区,则保留整个内存块 */
|
||||
if (iter->keep)
|
||||
if (iter->keep) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* 计算当前内存块被使用的内存大小 */
|
||||
n = iter->addr - iter->buf;
|
||||
@ -157,8 +159,9 @@ int acl_dbuf_pool_reset(ACL_DBUF_POOL *pool, size_t off)
|
||||
/* off 为下一个内存块的 addr 所在的相对偏移位置 */
|
||||
pool->off -=n;
|
||||
|
||||
if (tmp->size > pool->block_size)
|
||||
if (tmp->size > pool->block_size) {
|
||||
pool->huge--;
|
||||
}
|
||||
|
||||
#ifdef USE_VALLOC
|
||||
free(tmp);
|
||||
@ -198,20 +201,23 @@ int acl_dbuf_pool_free(ACL_DBUF_POOL *pool, const void *addr)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (iter->used > 0 || iter->keep)
|
||||
if (iter->used > 0 || iter->keep) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* should free the ACL_DBUF block */
|
||||
|
||||
if (iter == pool->head)
|
||||
if (iter == pool->head) {
|
||||
pool->head = iter->next;
|
||||
else
|
||||
} else {
|
||||
prev->next = iter->next;
|
||||
}
|
||||
|
||||
pool->off -= iter->addr - iter->buf;
|
||||
|
||||
if (iter->size > pool->block_size)
|
||||
if (iter->size > pool->block_size) {
|
||||
pool->huge--;
|
||||
}
|
||||
|
||||
acl_myfree(iter);
|
||||
|
||||
@ -234,8 +240,9 @@ static ACL_DBUF *acl_dbuf_alloc(ACL_DBUF_POOL *pool, size_t length)
|
||||
dbuf->addr = dbuf->buf;
|
||||
|
||||
pool->head = dbuf;
|
||||
if (length > pool->block_size)
|
||||
if (length > pool->block_size) {
|
||||
pool->huge++;
|
||||
}
|
||||
|
||||
pool->count++;
|
||||
return dbuf;
|
||||
@ -248,17 +255,16 @@ void *acl_dbuf_pool_alloc(ACL_DBUF_POOL *pool, size_t length)
|
||||
|
||||
length += 4 - length % 4;
|
||||
|
||||
if (length > pool->block_size)
|
||||
if (length > pool->block_size) {
|
||||
dbuf = acl_dbuf_alloc(pool, length);
|
||||
else if (pool->head == NULL)
|
||||
} else if (pool->head == NULL) {
|
||||
dbuf = acl_dbuf_alloc(pool, pool->block_size);
|
||||
else if (pool->block_size < ((char*) pool->head->addr
|
||||
- (char*) pool->head->buf) + length)
|
||||
{
|
||||
} else if (pool->block_size < ((char*) pool->head->addr
|
||||
- (char*) pool->head->buf) + length) {
|
||||
dbuf = acl_dbuf_alloc(pool, pool->block_size);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
dbuf = pool->head;
|
||||
}
|
||||
|
||||
ptr = dbuf->addr;
|
||||
dbuf->addr = (char*) dbuf->addr + length;
|
||||
@ -273,8 +279,9 @@ void *acl_dbuf_pool_calloc(ACL_DBUF_POOL *pool, size_t length)
|
||||
void *ptr;
|
||||
|
||||
ptr = acl_dbuf_pool_alloc(pool, length);
|
||||
if (ptr)
|
||||
if (ptr) {
|
||||
memset(ptr, 0, length);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@ -293,8 +300,9 @@ char *acl_dbuf_pool_strndup(ACL_DBUF_POOL *pool, const char *s, size_t len)
|
||||
char *ptr;
|
||||
size_t n = strlen(s);
|
||||
|
||||
if (n > len)
|
||||
if (n > len) {
|
||||
n = len;
|
||||
}
|
||||
ptr = (char*) acl_dbuf_pool_alloc(pool, n + 1);
|
||||
memcpy(ptr, s, n);
|
||||
ptr[n] = 0;
|
||||
@ -317,8 +325,9 @@ int acl_dbuf_pool_keep(ACL_DBUF_POOL *pool, const void *addr)
|
||||
while (iter) {
|
||||
if (ptr < iter->addr && ptr >= iter->buf) {
|
||||
iter->keep++;
|
||||
if (iter->keep <= iter->used)
|
||||
if (iter->keep <= iter->used) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
acl_msg_warn("warning: %s(%d), keep(%d) > used(%d)",
|
||||
__FUNCTION__, __LINE__,
|
||||
@ -342,8 +351,9 @@ int acl_dbuf_pool_unkeep(ACL_DBUF_POOL *pool, const void *addr)
|
||||
while (iter) {
|
||||
if (ptr < iter->addr && ptr >= iter->buf) {
|
||||
iter->keep--;
|
||||
if (iter->keep >= 0)
|
||||
if (iter->keep >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
acl_msg_warn("warning: %s(%d), keep(%d) < 0",
|
||||
__FUNCTION__, __LINE__, iter->keep);
|
||||
|
@ -34,9 +34,9 @@ static ACL_VSTREAM *acl_safe_open_exist(const char *path, int flags,
|
||||
{
|
||||
struct stat local_statbuf;
|
||||
struct stat lstat_st;
|
||||
int saved_error;
|
||||
int saved_error;
|
||||
char tbuf[256];
|
||||
ACL_VSTREAM *fp;
|
||||
char tbuf[256];
|
||||
|
||||
/*
|
||||
* Open an existing file.
|
||||
@ -49,7 +49,7 @@ static ACL_VSTREAM *acl_safe_open_exist(const char *path, int flags,
|
||||
path, acl_last_strerror(tbuf, sizeof(tbuf)));
|
||||
}
|
||||
acl_set_error(saved_error);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -57,19 +57,23 @@ static ACL_VSTREAM *acl_safe_open_exist(const char *path, int flags,
|
||||
* link (so that someone can't lure us into clobbering a sensitive file
|
||||
* by making a hard link to it), and it must be a non-symlink file.
|
||||
*/
|
||||
if (fstat_st == 0)
|
||||
if (fstat_st == 0) {
|
||||
fstat_st = &local_statbuf;
|
||||
}
|
||||
|
||||
if (fstat(ACL_VSTREAM_FILE(fp), fstat_st) < 0) {
|
||||
acl_msg_fatal("%s: bad open file status: %s", path,
|
||||
acl_last_strerror(tbuf, sizeof(tbuf)));
|
||||
} else if (S_ISDIR(fstat_st->st_mode)) {
|
||||
if (why)
|
||||
if (why) {
|
||||
acl_vstring_sprintf(why, "file is a directory");
|
||||
}
|
||||
acl_set_error(EISDIR);
|
||||
} else if (fstat_st->st_nlink != 1) {
|
||||
if (why)
|
||||
if (why) {
|
||||
acl_vstring_sprintf(why, "file has %d hard links",
|
||||
(int) fstat_st->st_nlink);
|
||||
(int) fstat_st->st_nlink);
|
||||
}
|
||||
acl_set_error(EPERM);
|
||||
}
|
||||
|
||||
@ -90,15 +94,18 @@ static ACL_VSTREAM *acl_safe_open_exist(const char *path, int flags,
|
||||
* delivering mail to a world-writable mailbox directory.
|
||||
*/
|
||||
else if (lstat(path, &lstat_st) < 0) {
|
||||
if (why)
|
||||
if (why) {
|
||||
acl_vstring_sprintf(why, "file status changed unexpectedly: %s",
|
||||
acl_last_strerror(tbuf, sizeof(tbuf)));
|
||||
}
|
||||
acl_set_error(EPERM);
|
||||
} else if (S_ISLNK(lstat_st.st_mode)) {
|
||||
if (lstat_st.st_uid == 0)
|
||||
return (fp);
|
||||
if (why)
|
||||
if (lstat_st.st_uid == 0) {
|
||||
return fp;
|
||||
}
|
||||
if (why) {
|
||||
acl_vstring_sprintf(why, "file is a symbolic link");
|
||||
}
|
||||
acl_set_error(EPERM);
|
||||
} else if (fstat_st->st_dev != lstat_st.st_dev
|
||||
|| fstat_st->st_ino != lstat_st.st_ino
|
||||
@ -107,8 +114,9 @@ static ACL_VSTREAM *acl_safe_open_exist(const char *path, int flags,
|
||||
#endif
|
||||
|| fstat_st->st_nlink != lstat_st.st_nlink
|
||||
|| fstat_st->st_mode != lstat_st.st_mode) {
|
||||
if (why)
|
||||
if (why) {
|
||||
acl_vstring_sprintf(why, "file status changed unexpectedly");
|
||||
}
|
||||
acl_set_error(EPERM);
|
||||
}
|
||||
|
||||
@ -116,14 +124,14 @@ static ACL_VSTREAM *acl_safe_open_exist(const char *path, int flags,
|
||||
* We are almost there...
|
||||
*/
|
||||
else {
|
||||
return (fp);
|
||||
return fp;
|
||||
}
|
||||
|
||||
/*
|
||||
* End up here in case of fstat()/lstat() problems or inconsistencies.
|
||||
*/
|
||||
acl_vstream_fclose(fp);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* acl_safe_open_create - create new file */
|
||||
@ -140,10 +148,11 @@ static ACL_VSTREAM *acl_safe_open_create(const char *path, int flags, int mode,
|
||||
*/
|
||||
fp = acl_vstream_fopen(path, flags | (O_CREAT | O_EXCL), mode, 4096);
|
||||
if (fp == 0) {
|
||||
if (why)
|
||||
if (why) {
|
||||
acl_vstring_sprintf(why, "cannot create file exclusively: %s",
|
||||
acl_last_strerror(tbuf, sizeof(tbuf)));
|
||||
return (0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -161,22 +170,23 @@ static ACL_VSTREAM *acl_safe_open_create(const char *path, int flags, int mode,
|
||||
/*
|
||||
* Optionally look up the file attributes.
|
||||
*/
|
||||
if (st != 0 && fstat(ACL_VSTREAM_FILE(fp), st) < 0)
|
||||
if (st != 0 && fstat(ACL_VSTREAM_FILE(fp), st) < 0) {
|
||||
acl_msg_fatal("%s: bad open file status: %s",
|
||||
path, acl_last_strerror(tbuf, sizeof(tbuf)));
|
||||
}
|
||||
|
||||
/*
|
||||
* We are almost there...
|
||||
*/
|
||||
else {
|
||||
return (fp);
|
||||
return fp;
|
||||
}
|
||||
|
||||
/*
|
||||
* End up here in case of trouble.
|
||||
*/
|
||||
acl_vstream_fclose(fp);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* acl_safe_open - safely open or create file */
|
||||
@ -185,22 +195,20 @@ ACL_VSTREAM *acl_safe_open(const char *path, int flags, int mode,
|
||||
struct stat * st, uid_t user, gid_t group, ACL_VSTRING *why)
|
||||
{
|
||||
ACL_VSTREAM *fp;
|
||||
|
||||
switch (flags & (O_CREAT | O_EXCL)) {
|
||||
unsigned f = ((unsigned) flags) & (O_CREAT | O_EXCL);
|
||||
|
||||
/*
|
||||
* Open an existing file, carefully.
|
||||
*/
|
||||
case 0:
|
||||
if (f == 0) {
|
||||
return (acl_safe_open_exist(path, flags, st, why));
|
||||
|
||||
} else if (f == (O_CREAT | O_EXCL)) {
|
||||
/*
|
||||
* Create a new file, carefully.
|
||||
*/
|
||||
case O_CREAT | O_EXCL:
|
||||
return (acl_safe_open_create(path, flags, mode,
|
||||
st, user, group, why));
|
||||
|
||||
return acl_safe_open_create(path, flags, mode,
|
||||
st, user, group, why);
|
||||
} else if (f == O_CREAT) {
|
||||
/*
|
||||
* Open an existing file or create a new one, carefully.
|
||||
* When opening an existing file, we are prepared to deal
|
||||
@ -208,26 +216,25 @@ ACL_VSTREAM *acl_safe_open(const char *path, int flags, int mode,
|
||||
* are prepared for "file exists" errors only. Any other
|
||||
* error means we better give up trying.
|
||||
*/
|
||||
case O_CREAT:
|
||||
fp = acl_safe_open_exist(path, flags, st, why);
|
||||
if (fp == 0 && acl_last_error() == ENOENT) {
|
||||
fp = acl_safe_open_create(path, flags, mode, st,
|
||||
user, group, why);
|
||||
if (fp == 0 && acl_last_error() == EEXIST)
|
||||
user, group, why);
|
||||
if (fp == 0 && acl_last_error() == EEXIST) {
|
||||
fp = acl_safe_open_exist(path, flags, st, why);
|
||||
}
|
||||
}
|
||||
return (fp);
|
||||
|
||||
return fp;
|
||||
} else {
|
||||
/*
|
||||
* Interface violation. Sorry, but we must be strict.
|
||||
*/
|
||||
default:
|
||||
acl_msg_panic("acl_safe_open: O_EXCL flag without O_CREAT flag");
|
||||
}
|
||||
|
||||
/* no reache here */
|
||||
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* ACL_UNIX */
|
||||
|
@ -73,6 +73,15 @@ ifeq ($(findstring clang++, $(CC)), clang++)
|
||||
-Wno-invalid-offsetof
|
||||
endif
|
||||
|
||||
ifeq ($(findstring cosmoc+, $(CC)), cosmoc+)
|
||||
CFLAGS += -DCOSMOCC
|
||||
CFLAGS += -Wno-implicit-fallthrough
|
||||
CFLAGS += -DLINUX2
|
||||
CFLAGS += -fexceptions
|
||||
AR = cosmoar
|
||||
|
||||
endif
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
UNIXTYPE = FREEBSD
|
||||
@ -159,10 +168,12 @@ ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
|
||||
CFLAGS += -DHAS_POLARSSL_DLL
|
||||
endif
|
||||
|
||||
ifeq ($(MBEDTLS_STATIC), yes)
|
||||
CFLAGS += -DHAS_MBEDTLS
|
||||
else
|
||||
CFLAGS += -DHAS_MBEDTLS_DLL
|
||||
ifneq ($(findstring cosmoc+, $(CC)), cosmoc+)
|
||||
ifeq ($(MBEDTLS_STATIC), yes)
|
||||
CFLAGS += -DHAS_MBEDTLS
|
||||
else
|
||||
CFLAGS += -DHAS_MBEDTLS_DLL
|
||||
endif
|
||||
endif
|
||||
|
||||
shared_ldflags = -lprotocol -lacl -lrt -lpthread -lz -ldl
|
||||
|
@ -34,12 +34,12 @@ public:
|
||||
* @param size {size_t} 由编译传入的 dbuf_pool 对象的长度大小
|
||||
* @param nblock {size_t} 内部采用的内存块(4096)的倍数
|
||||
*/
|
||||
void *operator new(size_t size, size_t nblock = 2);
|
||||
static void *operator new(size_t size, size_t nblock = 2);
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
void operator delete(void* ptr, size_t);
|
||||
static void operator delete(void* ptr, size_t);
|
||||
#endif
|
||||
void operator delete(void* ptr);
|
||||
static void operator delete(void* ptr);
|
||||
|
||||
/**
|
||||
* 重置内存池的状态以便于重复使用该内存池对象
|
||||
|
@ -47,6 +47,15 @@ ifeq ($(findstring clang++, $(CC)), clang++)
|
||||
-Wno-invalid-offsetof
|
||||
endif
|
||||
|
||||
ifeq ($(findstring cosmoc+, $(CC)), cosmoc+)
|
||||
CFLAGS += -DCOSMOCC
|
||||
CFLAGS += -DLINUX2
|
||||
CFLAGS += -Wno-implicit-fallthrough
|
||||
CFLAGS += -fexceptions
|
||||
|
||||
endif
|
||||
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(OSNAME)), FreeBSD)
|
||||
CFLAGS += -DFREEBSD
|
||||
|
@ -35,6 +35,7 @@ static void test1(int nblock, int capacity, int incr, int max, int pos) {
|
||||
dbuf.set_increment((size_t) incr);
|
||||
myobj* o;
|
||||
std::list<myobj*, acl::dbuf_allocator<myobj*> > objs;
|
||||
//std::list<myobj*> objs;
|
||||
|
||||
for (int i = 0; i < max; i++) {
|
||||
o = dbuf.create<myobj>(&dbuf, i);
|
||||
@ -66,8 +67,6 @@ static void test1(int nblock, int capacity, int incr, int max, int pos) {
|
||||
objs.clear();
|
||||
dbuf.dbuf_reset();
|
||||
|
||||
printf("\r\n----------------Again---------------\r\n");
|
||||
|
||||
for (int i = 0; i < max; i++) {
|
||||
o = dbuf.create<myobj>(&dbuf, i);
|
||||
if (i < 10) {
|
||||
|
0
lib_acl_cpp/samples/dbuf/dbuf1/valgrind.sh
Normal file → Executable file
0
lib_acl_cpp/samples/dbuf/dbuf1/valgrind.sh
Normal file → Executable file
0
lib_acl_cpp/samples/dbuf/dbuf3/valgrind.sh
Normal file → Executable file
0
lib_acl_cpp/samples/dbuf/dbuf3/valgrind.sh
Normal file → Executable file
@ -51,9 +51,13 @@
|
||||
#endif // ACL_CPP_DEBUG_MEM
|
||||
|
||||
#if defined(ACL_UNIX)
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <zlib.h>
|
||||
# include <pthread.h>
|
||||
# include <unistd.h>
|
||||
# ifdef COSMOCC
|
||||
# include <third_party/zlib/zlib.h>
|
||||
# else
|
||||
# include <zlib.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// 加入下面一行可以加快在 VC 下的编译速度
|
||||
@ -66,4 +70,3 @@
|
||||
#define ACL_CPP_DEBUG_HTTP_NET 42
|
||||
#define DEBUG_MQTT 43
|
||||
#define ACL_CPP_DEBUG_MAX 70
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include "acl_stdafx.hpp"
|
||||
|
||||
#if 0
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
# include "zlib-1.2.11/zlib.h"
|
||||
#else
|
||||
# include <zlib.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ACL_PREPARE_COMPILE
|
||||
#include "acl_cpp/stdlib/log.hpp"
|
||||
|
@ -25,10 +25,15 @@ void *dbuf_pool::operator new(size_t size, size_t nblock /* = 2 */)
|
||||
if (nblock == 0) {
|
||||
nblock = 2;
|
||||
}
|
||||
|
||||
ACL_DBUF_POOL* pool = acl_dbuf_pool_create(4096 * nblock);
|
||||
dbuf_pool* dbuf = (dbuf_pool*) acl_dbuf_pool_alloc(pool, size);
|
||||
dbuf->pool_ = pool;
|
||||
dbuf->mysize_ = size;
|
||||
assert(pool);
|
||||
|
||||
dbuf_pool* dbuf = (dbuf_pool*) acl_dbuf_pool_alloc(pool, size);
|
||||
assert(dbuf);
|
||||
|
||||
dbuf->pool_ = pool;
|
||||
dbuf->mysize_ = size;
|
||||
|
||||
return dbuf;
|
||||
}
|
||||
@ -49,8 +54,7 @@ void dbuf_pool::operator delete(void* ptr)
|
||||
|
||||
bool dbuf_pool::dbuf_reset(size_t reserve /* = 0 */)
|
||||
{
|
||||
return acl_dbuf_pool_reset(pool_, mysize_ + reserve) == 0
|
||||
? true : false;
|
||||
return acl_dbuf_pool_reset(pool_, mysize_ + reserve) == 0;
|
||||
}
|
||||
|
||||
void* dbuf_pool::dbuf_alloc(size_t len)
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
# include "zlib-1.2.11/zlib.h"
|
||||
#elif defined(COSMOCC)
|
||||
# include <third_party/zlib/zlib.h>
|
||||
#else
|
||||
# include <zlib.h>
|
||||
#endif
|
||||
@ -187,11 +189,16 @@ static void __zlib_dll_load(void)
|
||||
|
||||
# else
|
||||
//# define __deflateInit deflateInit_
|
||||
# define __deflateInit2 deflateInit2_
|
||||
# ifdef COSMOCC
|
||||
# define __deflateInit2 deflateInit2
|
||||
# define __inflateInit2 inflateInit2
|
||||
# else
|
||||
# define __deflateInit2 deflateInit2_
|
||||
# define __inflateInit2 inflateInit2_
|
||||
# endif
|
||||
# define __deflate deflate
|
||||
# define __deflateReset deflateReset
|
||||
# define __deflateEnd deflateEnd
|
||||
# define __inflateInit2 inflateInit2_
|
||||
# define __inflate inflate
|
||||
# define __inflateReset inflateReset
|
||||
# define __inflateEnd inflateEnd
|
||||
@ -551,9 +558,14 @@ bool zlib_stream::zip_begin(zlib_level_t level /* = zlib_default */,
|
||||
is_compress_ = true;
|
||||
// int ret = __deflateInit(zstream_, level, ZLIB_VERSION, sizeof(z_stream));
|
||||
|
||||
#ifdef COSMOCC
|
||||
int ret = __deflateInit2(zstream_, level, Z_DEFLATED,
|
||||
wbits, mlevel, Z_DEFAULT_STRATEGY);
|
||||
#else
|
||||
int ret = __deflateInit2(zstream_, level, Z_DEFLATED,
|
||||
wbits, mlevel, Z_DEFAULT_STRATEGY, ZLIB_VERSION,
|
||||
(int) sizeof(z_stream));
|
||||
#endif
|
||||
if (ret != Z_OK) {
|
||||
logger_error("deflateInit error");
|
||||
return false;
|
||||
@ -639,8 +651,12 @@ bool zlib_stream::unzip_begin(bool have_zlib_header /* = true */,
|
||||
finished_ = false;
|
||||
is_compress_ = false;
|
||||
|
||||
#ifdef COSMOCC
|
||||
int ret = __inflateInit2(zstream_, have_zlib_header ? wsize : -wsize);
|
||||
#else
|
||||
int ret = __inflateInit2(zstream_, have_zlib_header ?
|
||||
wsize : -wsize, ZLIB_VERSION, sizeof(z_stream));
|
||||
#endif
|
||||
if (ret != Z_OK) {
|
||||
logger_error("inflateInit error");
|
||||
return (false);
|
||||
|
@ -90,6 +90,14 @@ ifeq ($(findstring clang++, $(CC)), clang++)
|
||||
-Wno-invalid-offsetof
|
||||
endif
|
||||
|
||||
ifeq ($(findstring cosmocc, $(CC)), cosmocc)
|
||||
CFLAGS += -DCOSMOCC
|
||||
CFLAGS += -Wno-implicit-fallthrough
|
||||
CFLAGS += -DLINUX2
|
||||
AR = cosmoar
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(findstring arm64, $(UNIXNAME)), arm64)
|
||||
JMP_CTX = USE_BOOST_JMP
|
||||
endif
|
||||
@ -222,6 +230,7 @@ SRC = $(wildcard $(SRC_PATH_SRC)/*.c) \
|
||||
$(wildcard $(SRC_PATH_SRC)/sync/*.c)
|
||||
|
||||
#ASM_OBJ=$(OBJ_PATH_DST)/setjmp.o $(OBJ_PATH_DST)/make_gas.o $(OBJ_PATH_DST)/jump_gas.o
|
||||
|
||||
ASM_OBJ=$(OBJ_PATH_DST)/make_gas.o $(OBJ_PATH_DST)/jump_gas.o
|
||||
OBJ = $(patsubst %.c, $(OBJ_PATH_DST)/%.o, $(notdir $(SRC))) $(ASM_OBJ)
|
||||
|
||||
|
@ -326,7 +326,7 @@ long thread_self(void)
|
||||
return (long) GetCurrentThreadId();
|
||||
}
|
||||
|
||||
#elif defined(__linux__)
|
||||
#elif defined(__linux__) || defined(COSMOCC)
|
||||
|
||||
#include <sys/syscall.h>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __DEFINE_INCLUDE_H__
|
||||
#define __DEFINE_INCLUDE_H__
|
||||
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) || defined(LINUX2)
|
||||
# define LINUX
|
||||
# define SYS_UNIX
|
||||
# define HAS_SELECT
|
||||
|
@ -1018,11 +1018,13 @@ static size_t save_addr2rr(int type, const char *src, RFC1035_RR *rr)
|
||||
in6.sin6_port = htons(0);
|
||||
|
||||
#if defined(SYS_UNIX) || (defined(SYS_WIN) && _MSC_VER >= 1600)
|
||||
# if !defined(COSMOCC)
|
||||
if (ptr && *ptr && !(in6.sin6_scope_id = if_nametoindex(ptr))) {
|
||||
msg_error("%s(%d): if_nametoindex error %s",
|
||||
__FUNCTION__, __LINE__, last_serror());
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
if (inet_pton(AF_INET6, buf, &in6.sin6_addr) == 0) {
|
||||
msg_error("%s(%d): invalid addr=%s",
|
||||
|
@ -6,7 +6,12 @@
|
||||
#include "common/timer_cache.h"
|
||||
|
||||
#ifdef HAS_EPOLL
|
||||
#include <sys/epoll.h>
|
||||
# ifdef COSMOCC
|
||||
# include <libc/sysv/consts/epoll.h>
|
||||
# include <libc/sock/epoll.h>
|
||||
# else
|
||||
# include <sys/epoll.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAS_IO_URING
|
||||
|
@ -7,7 +7,14 @@
|
||||
#define __USE_GNU
|
||||
#endif
|
||||
#include <dlfcn.h>
|
||||
#include <sys/epoll.h>
|
||||
|
||||
#ifdef COSMOCC
|
||||
# include <libc/sysv/consts/epoll.h>
|
||||
# include <libc/sock/epoll.h>
|
||||
#else
|
||||
# include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#include "event.h"
|
||||
#include "event_epoll.h"
|
||||
|
||||
|
@ -41,11 +41,13 @@ static struct addrinfo *create_addrinfo(const char *ip, short port,
|
||||
sa.in6.sin6_family = AF_INET6;
|
||||
sa.in6.sin6_port = htons(port);
|
||||
|
||||
#ifndef COSMOCC
|
||||
if (ptr && *ptr) {
|
||||
if (!(in6->sin6_scope_id = if_nametoindex(ptr))) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (inet_pton(AF_INET6, buf, &sa.in6.sin6_addr) <= 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -3,6 +3,13 @@
|
||||
|
||||
#include "fiber/fiber_define.h"
|
||||
|
||||
#ifdef COSMOCC
|
||||
# include <libc/sysv/consts/epoll.h>
|
||||
# include <libc/sock/epoll.h>
|
||||
#elif defined(__linux__) || defined(LINUX2)
|
||||
# include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -35,7 +42,7 @@ typedef int (WSAAPI *WSARecv_fn)(socket_t, LPWSABUF, DWORD, LPDWORD, LPDWORD,
|
||||
typedef socket_t (WSAAPI *WSAAccept_fn)(SOCKET, struct sockaddr FAR *,
|
||||
LPINT, LPCONDITIONPROC, DWORD_PTR);
|
||||
|
||||
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(MINGW)
|
||||
#elif defined(__linux__) || defined(LINUX2) || defined(__APPLE__) || defined(__FreeBSD__) || defined(MINGW)
|
||||
|
||||
typedef int (*fcntl_fn)(int, int, ...);
|
||||
typedef int (*setsockopt_fn)(socket_t, int, int, const void *, socklen_t);
|
||||
@ -143,7 +150,7 @@ extern gethostbyname_fn *sys_gethostbyname;
|
||||
extern WSARecv_fn *sys_WSARecv;
|
||||
extern WSAAccept_fn *sys_WSAAccept;
|
||||
|
||||
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(MINGW) // SYS_UNIX
|
||||
#elif defined(__linux__) || defined(LINUX2) || defined(__APPLE__) || defined(__FreeBSD__) || defined(MINGW) // SYS_UNIX
|
||||
|
||||
extern fcntl_fn *sys_fcntl;
|
||||
extern setsockopt_fn *sys_setsockopt;
|
||||
@ -197,7 +204,7 @@ extern pwrite_fn *sys_pwrite;
|
||||
// in hook.c
|
||||
void hook_once(void);
|
||||
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) || defined(LINUX2)
|
||||
// in epoll.c
|
||||
int epoll_try_register(int epfd);
|
||||
int epoll_close(int epfd);
|
||||
|
@ -20,7 +20,7 @@ ssize_t fiber_sendto(FILE_EVENT *fe, const void *buf, size_t len,
|
||||
int flags, const struct sockaddr *dest_addr, socklen_t addrlen);
|
||||
ssize_t fiber_sendmsg(FILE_EVENT *fe, const struct msghdr *msg, int flags);
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(MINGW) // SYS_UNIX
|
||||
#if defined(__linux__) || defined(LINUX2) || defined(__APPLE__) || defined(__FreeBSD__) || defined(MINGW) // SYS_UNIX
|
||||
|
||||
// in fiber_read.c
|
||||
int fiber_iocp_read(FILE_EVENT *fe, char *buf, int len);
|
||||
|
@ -62,9 +62,14 @@
|
||||
#define GETPID _getpid
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) || defined(LINUX2)
|
||||
# include <sys/sendfile.h>
|
||||
# include <sys/epoll.h>
|
||||
# ifdef COSMOCC
|
||||
# include <libc/sysv/consts/epoll.h>
|
||||
# include <libc/sock/epoll.h>
|
||||
# else
|
||||
# include <sys/epoll.h>
|
||||
# endif
|
||||
|
||||
/*
|
||||
# if !defined(__aarch64__) && !defined(__arm__)
|
||||
|
@ -56,6 +56,13 @@ ifeq ($(findstring clang++, $(CC)), clang++)
|
||||
-Wno-invalid-offsetof
|
||||
endif
|
||||
|
||||
ifeq ($(findstring cosmocc, $(CC)), cosmocc)
|
||||
CFLAGS += -DCOSMOCC
|
||||
CFLAGS += -Wno-implicit-fallthrough
|
||||
CFLAGS += -DLINUX2
|
||||
|
||||
endif
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
CFLAGS += -DFREEBSD
|
||||
|
@ -62,6 +62,14 @@ ifeq ($(findstring clang++, $(CC)), clang++)
|
||||
-Wno-invalid-offsetof
|
||||
endif
|
||||
|
||||
ifeq ($(findstring cosmocc, $(CC)), cosmocc)
|
||||
CFLAGS += -DCOSMOCC
|
||||
CFLAGS += -Wno-implicit-fallthrough
|
||||
CFLAGS += -DLINUX2
|
||||
AR = cosmoar
|
||||
|
||||
endif
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
UNIXTYPE = FREEBSD
|
||||
|
Loading…
Reference in New Issue
Block a user