OS macro defines put in _os_define.h
parent
8045a6fa82
commit
e610e8a45d
5
HISTORY
5
HISTORY
|
|
@ -1,4 +1,9 @@
|
|||
|
||||
Version 1.18 2015-07-15
|
||||
* OS macro defines put in _os_define.h
|
||||
* remove file _os_bits.h
|
||||
* schedule task support second field
|
||||
|
||||
Version 1.17 2015-07-14
|
||||
* ini_file_reader.c change PJWHash to Time33Hash and increase capacity
|
||||
* ini_file_reader.c realloc change to malloc and memcpy
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
%define LibFastcommonDevel libfastcommon-devel
|
||||
|
||||
Name: libfastcommon
|
||||
Version: 1.0.17
|
||||
Version: 1.0.18
|
||||
Release: 1%{?dist}
|
||||
Summary: c common functions library extracted from my open source projects FastDFS
|
||||
License: GPL
|
||||
|
|
|
|||
50
make.sh
50
make.sh
|
|
@ -46,16 +46,6 @@ else
|
|||
OFF_BITS=32
|
||||
fi
|
||||
|
||||
cat <<EOF > src/_os_bits.h
|
||||
#ifndef _OS_BITS_H
|
||||
#define _OS_BITS_H
|
||||
|
||||
#define OS_BITS $OS_BITS
|
||||
#define OFF_BITS $OFF_BITS
|
||||
|
||||
#endif
|
||||
EOF
|
||||
|
||||
DEBUG_FLAG=1
|
||||
|
||||
CFLAGS='-Wall -D_FILE_OFFSET_BITS=64'
|
||||
|
|
@ -67,24 +57,54 @@ fi
|
|||
|
||||
LIBS=''
|
||||
uname=`uname`
|
||||
|
||||
if [ "$uname" = "Linux" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_LINUX -DIOEVENT_USE_EPOLL"
|
||||
OS_NAME=OS_LINUX
|
||||
IOEVENT_USE=IOEVENT_USE_EPOLL
|
||||
elif [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_FREEBSD -DIOEVENT_USE_KQUEUE"
|
||||
OS_NAME=OS_FREEBSD
|
||||
IOEVENT_USE=IOEVENT_USE_KQUEUE
|
||||
if [ "$uname" = "Darwin" ]; then
|
||||
CFLAGS="$CFLAGS -DDARWIN"
|
||||
fi
|
||||
elif [ "$uname" = "SunOS" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_SUNOS -D_THREAD_SAFE -DIOEVENT_USE_PORT"
|
||||
OS_NAME=OS_SUNOS
|
||||
IOEVENT_USE=IOEVENT_USE_PORT
|
||||
CFLAGS="$CFLAGS -D_THREAD_SAFE"
|
||||
LIBS="$LIBS -lsocket -lnsl -lresolv"
|
||||
export CC=gcc
|
||||
elif [ "$uname" = "AIX" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_AIX -D_THREAD_SAFE"
|
||||
OS_NAME=OS_AIX
|
||||
IOEVENT_USE=IOEVENT_USE_NONE
|
||||
CFLAGS="$CFLAGS -D_THREAD_SAFE"
|
||||
export CC=gcc
|
||||
elif [ "$uname" = "HP-UX" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_HPUX"
|
||||
OS_NAME=OS_HPUX
|
||||
IOEVENT_USE=IOEVENT_USE_NONE
|
||||
else
|
||||
OS_NAME=OS_UNKOWN
|
||||
IOEVENT_USE=IOEVENT_USE_NONE
|
||||
fi
|
||||
|
||||
cat <<EOF > src/_os_define.h
|
||||
#ifndef _OS_DEFINE_H
|
||||
#define _OS_DEFINE_H
|
||||
|
||||
#define OS_BITS $OS_BITS
|
||||
#define OFF_BITS $OFF_BITS
|
||||
|
||||
#ifndef $OS_NAME
|
||||
#define $OS_NAME 1
|
||||
#endif
|
||||
|
||||
#ifndef $IOEVENT_USE
|
||||
#define $IOEVENT_USE 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
EOF
|
||||
|
||||
|
||||
if [ -f /usr/lib/libpthread.so ] || [ -f /usr/local/lib/libpthread.so ] || [ -f /usr/lib64/libpthread.so ] || [ -f /usr/lib/libpthread.a ] || [ -f /usr/local/lib/libpthread.a ] || [ -f /usr/lib64/libpthread.a ]; then
|
||||
LIBS="$LIBS -lpthread"
|
||||
elif [ -f /usr/lib/libc_r.so ]; then
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ FAST_STATIC_OBJS = hash.o chain.o shared_func.o ini_file_reader.o \
|
|||
connection_pool.o fast_mpool.o
|
||||
|
||||
HEADER_FILES = common_define.h hash.h chain.h logger.h base64.h \
|
||||
shared_func.h pthread_func.h ini_file_reader.h _os_bits.h \
|
||||
shared_func.h pthread_func.h ini_file_reader.h _os_define.h \
|
||||
sockopt.h sched_thread.h http_func.h md5.h local_ip_func.h \
|
||||
avl_tree.h ioevent.h ioevent_loop.h fast_task_queue.h \
|
||||
fast_timer.h process_ctrl.h fast_mblock.h \
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
#ifndef _OS_BITS_H
|
||||
#define _OS_BITS_H
|
||||
|
||||
#define OS_BITS 64
|
||||
#define OFF_BITS 64
|
||||
|
||||
#endif
|
||||
|
|
@ -52,7 +52,7 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind);
|
|||
#define PTHREAD_MUTEX_ERRORCHECK PTHREAD_MUTEX_ERRORCHECK_NP
|
||||
#endif
|
||||
|
||||
#include "_os_bits.h"
|
||||
#include "_os_define.h"
|
||||
|
||||
#ifdef OS_BITS
|
||||
#if OS_BITS == 64
|
||||
|
|
@ -124,6 +124,7 @@ typedef struct
|
|||
{
|
||||
byte hour;
|
||||
byte minute;
|
||||
byte second;
|
||||
} TimeInfo;
|
||||
|
||||
typedef struct
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <stdint.h>
|
||||
#include <poll.h>
|
||||
#include <sys/time.h>
|
||||
#include "_os_define.h"
|
||||
|
||||
#define IOEVENT_TIMEOUT 0x8000
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,14 @@ static int sched_init_entries(ScheduleArray *pScheduleArray)
|
|||
|
||||
tm_base.tm_hour = pEntry->time_base.hour;
|
||||
tm_base.tm_min = pEntry->time_base.minute;
|
||||
if (pEntry->time_base.second >= 0 && pEntry->time_base.second <= 59)
|
||||
{
|
||||
tm_base.tm_sec = pEntry->time_base.second;
|
||||
}
|
||||
else
|
||||
{
|
||||
tm_base.tm_sec = 0;
|
||||
}
|
||||
time_base = mktime(&tm_base);
|
||||
|
||||
pEntry->next_call_time = g_current_time + \
|
||||
|
|
|
|||
|
|
@ -1819,6 +1819,8 @@ int get_time_item_from_conf(IniContext *pIniContext, \
|
|||
char *pValue;
|
||||
int hour;
|
||||
int minute;
|
||||
int second;
|
||||
int count;
|
||||
|
||||
pValue = iniGetStrValue(NULL, item_name, pIniContext);
|
||||
if (pValue == NULL)
|
||||
|
|
@ -1828,7 +1830,9 @@ int get_time_item_from_conf(IniContext *pIniContext, \
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (sscanf(pValue, "%d:%d", &hour, &minute) != 2)
|
||||
second = 0;
|
||||
count = sscanf(pValue, "%d:%d:%d", &hour, &minute, &second);
|
||||
if (count != 2 && count != 3)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"item \"%s\" 's value \"%s\" is not an valid time", \
|
||||
|
|
@ -1836,7 +1840,8 @@ int get_time_item_from_conf(IniContext *pIniContext, \
|
|||
return EINVAL;
|
||||
}
|
||||
|
||||
if ((hour < 0 || hour > 23) || (minute < 0 || minute > 59))
|
||||
if ((hour < 0 || hour > 23) || (minute < 0 || minute > 59)
|
||||
|| (second < 0 || second > 59))
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"item \"%s\" 's value \"%s\" is not an valid time", \
|
||||
|
|
@ -1846,6 +1851,7 @@ int get_time_item_from_conf(IniContext *pIniContext, \
|
|||
|
||||
pTimeInfo->hour = (byte)hour;
|
||||
pTimeInfo->minute = (byte)minute;
|
||||
pTimeInfo->second = (byte)second;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue