Changeset c4546c715aee6db46888e7ab0bb87fd2ce5357c6
- Timestamp:
- 06/18/08 03:53:18
(5 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1213761198 +0000
- git-parent:
[ab6d943800276f521272e785e85b9ea7130e92f1]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1213761198 +0000
- Message:
I sure hope this doesn't break other platforms too badly. Solaris support sans the eventer... untested, of course. refs #32.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rf318e95 |
rc4546c7 |
|
| 28 | 28 | fi |
|---|
| 29 | 29 | |
|---|
| 30 | | CPPFLAGS='-I$(top_srcdir)/src' |
|---|
| | 30 | CPPFLAGS="$CPPFLAGS "'-I$(top_srcdir)/src' |
|---|
| 31 | 31 | |
|---|
| 32 | 32 | case $host in |
|---|
| … | … | |
| 39 | 39 | ;; |
|---|
| 40 | 40 | *-*-solaris*) |
|---|
| | 41 | AC_MSG_CHECKING([32 or 64 bit Solaris assembly]) |
|---|
| | 42 | if test -n "`echo $CFLAGS | grep m64`"; then |
|---|
| | 43 | AC_MSG_RESULT([64]) |
|---|
| | 44 | ATOMIC_OBJS="noit_atomic_sol_x86_64.o" |
|---|
| | 45 | else |
|---|
| | 46 | AC_MSG_RESULT([32]) |
|---|
| | 47 | ATOMIC_OBJS="noit_atomic_sol_x86_32.o" |
|---|
| | 48 | fi |
|---|
| 41 | 49 | PICFLAGS="-Kpic" |
|---|
| 42 | 50 | MODULELD="$CC -G" |
|---|
| … | … | |
| 44 | 52 | MODULEEXT=so |
|---|
| 45 | 53 | RLDFLAG="-R" |
|---|
| | 54 | WHOLE_ARCHIVE="-Wl,-z -Wl,allextract" |
|---|
| | 55 | NOWHOLE_ARCHIVE="-Wl,-z -Wl,defaultextract" |
|---|
| 46 | 56 | ;; |
|---|
| 47 | 57 | *-*-openbsd*) |
|---|
| … | … | |
| 81 | 91 | AC_SUBST(WHOLE_ARCHIVE) |
|---|
| 82 | 92 | AC_SUBST(NOWHOLE_ARCHIVE) |
|---|
| | 93 | AC_SUBST(ATOMIC_OBJS) |
|---|
| 83 | 94 | AC_DEFINE_UNQUOTED(MODULEEXT, "$MODULEEXT", [module extension]) |
|---|
| 84 | 95 | |
|---|
| … | … | |
| 132 | 143 | ) |
|---|
| 133 | 144 | |
|---|
| | 145 | old_CFLAGS=$CFLAGS |
|---|
| 134 | 146 | AC_MSG_CHECKING([libpq includes]) |
|---|
| 135 | 147 | PQICFLAGS=`pg_config --includedir` |
|---|
| … | … | |
| 152 | 164 | [ AC_MSG_ERROR([Cannot compile/link against libpq]) ] |
|---|
| 153 | 165 | ) |
|---|
| | 166 | PGCFLAGS=$CFLAGS |
|---|
| | 167 | AC_SUBST(PGCFLAGS) |
|---|
| 154 | 168 | LIBS="$SAVELIBS" |
|---|
| | 169 | CFLAGS=$old_CFLAGS |
|---|
| 155 | 170 | |
|---|
| 156 | 171 | ######## |
|---|
| … | … | |
| 237 | 252 | |
|---|
| 238 | 253 | AC_FUNC_STRFTIME |
|---|
| 239 | | AC_CHECK_FUNC(ssetugid strlcpy strnstrn) |
|---|
| | 254 | AC_CHECK_FUNC(ssetugid strlcpy strnstrn openpty) |
|---|
| 240 | 255 | |
|---|
| 241 | 256 | # Checks for header files. |
|---|
| … | … | |
| 244 | 259 | ctype.h unistd.h time.h sys/stat.h sys/event.h libkern/OSAtomic.h \ |
|---|
| 245 | 260 | term.h termio.h termios.h curses.h sys/cdefs.h pwd.h netinet/in_systm.h \ |
|---|
| 246 | | sys/ioctl_compat.h util.h sys/time.h sys/mman.h) |
|---|
| | 261 | sys/ioctl_compat.h sys/filio.h util.h sys/time.h sys/mman.h \ |
|---|
| | 262 | stropts.h sys/stream.h) |
|---|
| 247 | 263 | |
|---|
| 248 | 264 | AC_CACHE_CHECK([for epoll support], ac_cv_have_epoll, [ |
|---|
| … | … | |
| 274 | 290 | AC_DEFINE_UNQUOTED(DEFAULT_EVENTER, "kqueue") |
|---|
| 275 | 291 | have_kqueue=1 |
|---|
| | 292 | fi |
|---|
| | 293 | |
|---|
| | 294 | AC_CACHE_CHECK([for Solaris ports support], ac_cv_have_ports, [ |
|---|
| | 295 | AC_TRY_LINK( |
|---|
| | 296 | [ #include <port.h> ], |
|---|
| | 297 | [ u_int a; a = port_create(); ], |
|---|
| | 298 | [ ac_cv_have_ports="yes" ], |
|---|
| | 299 | [ ac_cv_have_ports="no" ] |
|---|
| | 300 | ) |
|---|
| | 301 | ]) |
|---|
| | 302 | if test "x$ac_cv_have_ports" = "xyes" ; then |
|---|
| | 303 | AC_DEFINE(HAVE_PORTS) |
|---|
| | 304 | EVENTER_OBJS="$EVENTER_OBJS eventer_ports_impl.o" |
|---|
| | 305 | AC_DEFINE_UNQUOTED(DEFAULT_EVENTER, "ports") |
|---|
| | 306 | have_ports=1 |
|---|
| 276 | 307 | fi |
|---|
| 277 | 308 | |
|---|
| rf318e95 |
rc4546c7 |
|
| 2 | 2 | CPPFLAGS=@CPPFLAGS@ |
|---|
| 3 | 3 | CFLAGS=@CFLAGS@ |
|---|
| | 4 | PGCFLAGS=@PGCFLAGS@ |
|---|
| 4 | 5 | LDFLAGS=@LDFLAGS@ |
|---|
| 5 | 6 | AR=@AR@ |
|---|
| … | … | |
| 85 | 86 | @echo "- linking $@" |
|---|
| 86 | 87 | |
|---|
| | 88 | stratcon_datastore.o: |
|---|
| | 89 | @$(CC) $(CPPFLAGS) $(PGCFLAGS) -c $< |
|---|
| | 90 | @echo "- compiling $<" |
|---|
| | 91 | |
|---|
| 87 | 92 | .c.o: |
|---|
| 88 | 93 | @$(CC) $(CPPFLAGS) $(CFLAGS) -c $< |
|---|
| ref59bc7 |
rc4546c7 |
|
| 32 | 32 | void **fptr = malloc(sizeof(*fptr)); |
|---|
| 33 | 33 | *fptr = (void *)f; |
|---|
| 34 | | noit_hash_replace(&__name_to_func, strdup(name), strlen(name), f, free, NULL); |
|---|
| | 34 | noit_hash_replace(&__name_to_func, strdup(name), strlen(name), (void *)f, free, NULL); |
|---|
| 35 | 35 | noit_hash_replace(&__func_to_name, (char *)fptr, sizeof(*fptr), strdup(name), |
|---|
| 36 | 36 | free, free); |
|---|
| r5bf243f |
rc4546c7 |
|
| 5 | 5 | CPPFLAGS=@CPPFLAGS@ |
|---|
| 6 | 6 | CFLAGS=@CFLAGS@ |
|---|
| | 7 | PGCFLAGS=@PGCFLAGS@ |
|---|
| 7 | 8 | SHCFLAGS=@SHCFLAGS@ |
|---|
| 8 | 9 | MODULELD=@MODULELD@ |
|---|
| … | … | |
| 39 | 40 | @echo "- linking $@" |
|---|
| 40 | 41 | |
|---|
| | 42 | postgres.lo: postgres.c |
|---|
| | 43 | @$(CC) $(CPPFLAGS) $(SHCFLAGS) $(PGCFLAGS) -c $< -o $@ |
|---|
| | 44 | @echo "- compiling $<" |
|---|
| | 45 | |
|---|
| 41 | 46 | http.@MODULEEXT@: http.lo |
|---|
| 42 | 47 | @$(MODULELD) $(LDFLAGS) -o $@ http.lo @SERFLIBS@ ../serf/.libs/libserf-0.o -lz -lssl -lcrypto |
|---|
| … | … | |
| 55 | 60 | @echo "- linking $@" |
|---|
| 56 | 61 | |
|---|
| | 62 | ping_icmp.@MODULEEXT@: ping_icmp.lo |
|---|
| | 63 | @$(MODULELD) $(LDFLAGS) -o $@ $< |
|---|
| | 64 | @echo "- linking $@" |
|---|
| | 65 | |
|---|
| 57 | 66 | .lo.@MODULEEXT@: |
|---|
| 58 | 67 | @$(MODULELD) $(LDFLAGS) -o $@ $< |
|---|
| r53ed0eb |
rc4546c7 |
|
| 13 | 13 | #include "lua_noit.h" |
|---|
| 14 | 14 | |
|---|
| | 15 | #include <alloca.h> |
|---|
| 15 | 16 | #include <assert.h> |
|---|
| 16 | 17 | |
|---|
| … | … | |
| 382 | 383 | lua_pop(L, 1); |
|---|
| 383 | 384 | return rv; |
|---|
| 384 | | } else { |
|---|
| 385 | | lua_pop(L,1); |
|---|
| 386 | | noitL(nlerr, "%s.onload must return a integer\n", lmc->object); |
|---|
| 387 | | return -1; |
|---|
| 388 | | } |
|---|
| 389 | | return 0; |
|---|
| | 385 | } |
|---|
| | 386 | lua_pop(L,1); |
|---|
| | 387 | noitL(nlerr, "%s.onload must return a integer\n", lmc->object); |
|---|
| | 388 | return -1; |
|---|
| 390 | 389 | } |
|---|
| 391 | 390 | #define LMC_DECL(L, mod) \ |
|---|
| ra516f75 |
rc4546c7 |
|
| 21 | 21 | #include <netinet/in.h> |
|---|
| 22 | 22 | #include <arpa/inet.h> |
|---|
| | 23 | #ifdef HAVE_SYS_FILIO_H |
|---|
| | 24 | #include <sys/filio.h> |
|---|
| | 25 | #endif |
|---|
| 23 | 26 | |
|---|
| 24 | 27 | struct nl_slcl { |
|---|
| rc39dbcd |
rc4546c7 |
|
| 12 | 12 | #include <fcntl.h> |
|---|
| 13 | 13 | #include <sys/ioctl.h> |
|---|
| | 14 | #ifdef HAVE_SYS_FILIO_H |
|---|
| | 15 | #include <sys/filio.h> |
|---|
| | 16 | #endif |
|---|
| 14 | 17 | #ifdef HAVE_NETINET_IN_SYSTM_H |
|---|
| 15 | 18 | #include <netinet/in_systm.h> |
|---|
| rf7f34e8 |
rc4546c7 |
|
| 49 | 49 | #undef HAVE_TERMIOS_H |
|---|
| 50 | 50 | #undef HAVE_SYS_IOCTL_COMPAT_H |
|---|
| | 51 | #undef HAVE_SYS_FILIO_H |
|---|
| | 52 | #undef HAVE_STROPTS_H |
|---|
| | 53 | #undef HAVE_SYS_STREAM_H |
|---|
| 51 | 54 | #undef HAVE_UTIL_H |
|---|
| 52 | 55 | #undef HAVE_CURSES_H |
|---|
| … | … | |
| 97 | 100 | #undef HAVE_STRLCPY |
|---|
| 98 | 101 | #undef HAVE_STRNSTRN |
|---|
| | 102 | #undef HAVE_OPENPTY |
|---|
| 99 | 103 | |
|---|
| 100 | 104 | /* Kernel kqueue() support */ |
|---|
| … | … | |
| 225 | 229 | #endif |
|---|
| 226 | 230 | |
|---|
| 227 | | #endif |
|---|
| | 231 | #ifndef PATH_MAX |
|---|
| | 232 | #define PATH_MAX MAXPATHLEN |
|---|
| | 233 | #endif |
|---|
| | 234 | |
|---|
| | 235 | #endif |
|---|
| ra504323 |
rc4546c7 |
|
| 8 | 8 | #include <stdio.h> |
|---|
| 9 | 9 | #include <unistd.h> |
|---|
| | 10 | #include <alloca.h> |
|---|
| 10 | 11 | #include <errno.h> |
|---|
| 11 | 12 | #include <sys/ioctl.h> |
|---|
| | 13 | #include <sys/types.h> |
|---|
| | 14 | #include <sys/stat.h> |
|---|
| | 15 | #include <fcntl.h> |
|---|
| | 16 | #ifdef HAVE_STROPTS_H |
|---|
| | 17 | #include <stropts.h> |
|---|
| | 18 | #endif |
|---|
| | 19 | #ifdef HAVE_SYS_STREAM_H |
|---|
| | 20 | #include <sys/stream.h> |
|---|
| | 21 | #endif |
|---|
| 12 | 22 | #ifdef HAVE_TERMIOS_H |
|---|
| 13 | 23 | #include <termios.h> |
|---|
| … | … | |
| 259 | 269 | |
|---|
| 260 | 270 | int |
|---|
| | 271 | allocate_pty(int *master, int *slave) { |
|---|
| | 272 | #ifdef HAVE_OPENPTY |
|---|
| | 273 | return openpty(master, slave, NULL, NULL, NULL); |
|---|
| | 274 | #else |
|---|
| | 275 | /* STREAMS... sigh */ |
|---|
| | 276 | char *slavename; |
|---|
| | 277 | extern char *ptsname(); |
|---|
| | 278 | |
|---|
| | 279 | *master = open("/dev/ptmx", O_RDWR); /* open master */ |
|---|
| | 280 | if(*master < 0) return -1; |
|---|
| | 281 | grantpt(*master); /* change permission of slave */ |
|---|
| | 282 | unlockpt(*master); /* unlock slave */ |
|---|
| | 283 | slavename = ptsname(*master); /* get name of slave */ |
|---|
| | 284 | *slave = open(slavename, O_RDWR); /* open slave */ |
|---|
| | 285 | if(*slave < 0) { |
|---|
| | 286 | close(*master); |
|---|
| | 287 | *master = -1; |
|---|
| | 288 | return -1; |
|---|
| | 289 | } |
|---|
| | 290 | ioctl(*slave, I_PUSH, "ptem"); /* push ptem */ |
|---|
| | 291 | ioctl(*slave, I_PUSH, "ldterm"); /* push ldterm*/ |
|---|
| | 292 | return 0; |
|---|
| | 293 | #endif |
|---|
| | 294 | } |
|---|
| | 295 | |
|---|
| | 296 | int |
|---|
| 261 | 297 | noit_console_handler(eventer_t e, int mask, void *closure, |
|---|
| 262 | 298 | struct timeval *now) { |
|---|
| … | … | |
| 282 | 318 | int on = 1; |
|---|
| 283 | 319 | ncct->e = e; |
|---|
| 284 | | if(openpty(&ncct->pty_master, &ncct->pty_slave, NULL, NULL, NULL) || |
|---|
| | 320 | if(allocate_pty(&ncct->pty_master, &ncct->pty_slave) || |
|---|
| 285 | 321 | ioctl(ncct->pty_master, FIONBIO, &on)) { |
|---|
| 286 | 322 | nc_printf(ncct, "Failed to open pty: %s\n", strerror(errno)); |
|---|
| rfc879b8 |
rc4546c7 |
|
| 41 | 41 | #include <sys/ioctl_compat.h> |
|---|
| 42 | 42 | #endif |
|---|
| | 43 | #define TELOPTS |
|---|
| 43 | 44 | #include <arpa/telnet.h> |
|---|
| 44 | 45 | #include "noit_console.h" |
|---|
| rfc879b8 |
rc4546c7 |
|
| 50 | 50 | #include <termios.h> |
|---|
| 51 | 51 | #endif |
|---|
| | 52 | #ifdef HAVE_CURSES_H |
|---|
| | 53 | #include <curses.h> |
|---|
| | 54 | #endif |
|---|
| | 55 | #ifdef HAVE_TERMIO_H |
|---|
| | 56 | #include <termio.h> |
|---|
| | 57 | #endif |
|---|
| 52 | 58 | #ifdef HAVE_TERM_H |
|---|
| 53 | 59 | #include <term.h> |
|---|
| 54 | 60 | #endif |
|---|
| 55 | 61 | |
|---|
| 56 | | #if !defined(__linux__) |
|---|
| | 62 | #if !defined(__linux__) && !defined(__sun) |
|---|
| 57 | 63 | /* At least _I_ can't get LINUMODE working on Linux */ |
|---|
| 58 | 64 | #define LINEMODE 1 |
|---|
| ra504323 |
rc4546c7 |
|
| 55 | 55 | #endif |
|---|
| 56 | 56 | |
|---|
| | 57 | #ifndef MIN |
|---|
| | 58 | #define MIN(x,y) ((x) < (y) ? (x) : (y)) |
|---|
| 57 | 59 | #endif |
|---|
| | 60 | #ifndef MAX |
|---|
| | 61 | #define MAX(x,y) ((x) > (y) ? (x) : (y)) |
|---|
| | 62 | #endif |
|---|
| | 63 | #ifndef SUN_LEN |
|---|
| | 64 | #define SUN_LEN(ptr) (sizeof(*(ptr)) - sizeof((ptr)->sun_path) + strlen((ptr)->sun_path)) |
|---|
| | 65 | #endif |
|---|
| | 66 | |
|---|
| | 67 | #endif |
|---|
| r1f7cb6f |
rc4546c7 |
|
| 14 | 14 | #include <sys/socket.h> |
|---|
| 15 | 15 | #include <sys/ioctl.h> |
|---|
| | 16 | #ifdef HAVE_SYS_FILIO_H |
|---|
| | 17 | #include <sys/filio.h> |
|---|
| | 18 | #endif |
|---|
| 16 | 19 | #include <netinet/in.h> |
|---|
| 17 | 20 | |
|---|
| rc9fd28d |
rc4546c7 |
|
| 18 | 18 | #include <sys/types.h> |
|---|
| 19 | 19 | #include <sys/socket.h> |
|---|
| | 20 | #ifdef HAVE_SYS_FILIO_H |
|---|
| | 21 | #include <sys/filio.h> |
|---|
| | 22 | #endif |
|---|
| 20 | 23 | #include <netinet/in.h> |
|---|
| 21 | 24 | #include <sys/un.h> |
|---|
| rb0c153f |
rc4546c7 |
|
| 10 | 10 | top_srcdir=@top_srcdir@ |
|---|
| 11 | 11 | |
|---|
| 12 | | OBJS=noit_hash.o noit_skiplist.o noit_log.o noit_sem.o noit_str.o |
|---|
| | 12 | OBJS=noit_hash.o noit_skiplist.o noit_log.o noit_sem.o noit_str.o \ |
|---|
| | 13 | @ATOMIC_OBJS@ |
|---|
| 13 | 14 | |
|---|
| 14 | 15 | all: libnoit_utils.a |
|---|
| … | … | |
| 20 | 21 | @$(RANLIB) $@ |
|---|
| 21 | 22 | |
|---|
| | 23 | noit_atomic_sol_x86_32.o: noit_atomic_sol.s |
|---|
| | 24 | as -P -o $@ noit_atomic_sol.s |
|---|
| | 25 | |
|---|
| | 26 | noit_atomic_sol_x86_64.o: noit_atomic_sol.s |
|---|
| | 27 | as -P -xarch=generic64 -o $@ noit_atomic_sol.s |
|---|
| | 28 | |
|---|
| 22 | 29 | .c.o: |
|---|
| 23 | 30 | @$(CC) $(CPPFLAGS) $(CFLAGS) -c $< |
|---|
| r67a56d3 |
rc4546c7 |
|
| 41 | 41 | #error unsupported pointer width |
|---|
| 42 | 42 | #endif |
|---|
| | 43 | |
|---|
| 43 | 44 | |
|---|
| 44 | 45 | typedef noit_atomic32_t noit_spinlock_t; |
|---|
| … | … | |
| 89 | 90 | }; |
|---|
| 90 | 91 | #endif |
|---|
| | 92 | |
|---|
| | 93 | static inline void noit_spinlock_lock(volatile noit_spinlock_t *lock) { |
|---|
| | 94 | while(noit_atomic_cas32(lock, 1, 0) != 0); |
|---|
| | 95 | } |
|---|
| | 96 | static inline void noit_spinlock_unlock(volatile noit_spinlock_t *lock) { |
|---|
| | 97 | while(noit_atomic_cas32(lock, 0, 1) != 1); |
|---|
| | 98 | } |
|---|
| | 99 | static inline int noit_spinlock_trylock(volatile noit_spinlock_t *lock) { |
|---|
| | 100 | return (noit_atomic_cas32(lock, 1, 0) == 0); |
|---|
| | 101 | } |
|---|
| | 102 | |
|---|
| | 103 | #elif (defined(__amd64) || defined(__i386)) && (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) |
|---|
| | 104 | |
|---|
| | 105 | typedef noit_atomic32_t noit_spinlock_t; |
|---|
| | 106 | |
|---|
| | 107 | extern noit_atomic32_t noit_atomic_cas32(volatile noit_atomic32_t *mem, |
|---|
| | 108 | volatile noit_atomic32_t newval, volatile noit_atomic32_t cmpval); |
|---|
| | 109 | extern noit_atomic64_t noit_atomic_cas64(volatile noit_atomic64_t *mem, |
|---|
| | 110 | volatile noit_atomic64_t newval, volatile noit_atomic64_t cmpval); |
|---|
| 91 | 111 | |
|---|
| 92 | 112 | static inline void noit_spinlock_lock(volatile noit_spinlock_t *lock) { |
|---|
| ref59bc7 |
rc4546c7 |
|
| 19 | 19 | #include <stdlib.h> |
|---|
| 20 | 20 | #include <string.h> |
|---|
| | 21 | #include <alloca.h> |
|---|
| 21 | 22 | #include <assert.h> |
|---|
| 22 | 23 | |
|---|