Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

if QNX
export host_cpu
export QNXENV
endif

ACLOCAL_AMFLAGS = -I m4
AM_DISTCHECK_CONFIGURE_FLAGS = --without-mysql

Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ then
# TODO: Set flags for Gcov-enabled builds, if supported by Sun Studio
fi

# Check if we should compile for QNX
AC_ARG_VAR(QNXENV, compile for the QNX OS)

# Check for QNX (automake)
AM_CONDITIONAL([QNX], [test "x$QNXENV" = xtrue])

# Check if we should compile with MySQL support
AC_ARG_WITH([mysql],
Expand Down
2 changes: 1 addition & 1 deletion src/lua/internal/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SUFFIXES = .lua .lua.h

.lua.lua.h:
@echo "Creating $@ from $<"
@var=$$(echo $< | sed 's/\./_/g') && \
@var=$$(echo $< | xargs basename | sed 's/\./_/g') && \
( echo "unsigned char $${var}[] =" && \
sed -e 's/\\/\\\\/g' \
-e 's/"/\\"/g' \
Expand Down
21 changes: 21 additions & 0 deletions src/sb_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,33 @@
# include <string.h>
#endif

#ifdef __QNX__
#include <sys/syspage.h>
#include <sys/neutrino.h>
#include <inttypes.h>
#endif
#include "sb_logger.h"
#include "sb_timer.h"
#include "sb_util.h"

/* Some functions for simple time operations */


#ifdef __QNX__
int sb_timer_cycle_timer(struct timespec *tsp) {
static uint64_t cycles_per_sec = 0;
if (cycles_per_sec == 0) {
cycles_per_sec = SYSPAGE_ENTRY(qtime)->cycles_per_sec;
}
uint64_t count;
count = ClockCycles();
tsp->tv_sec= count/cycles_per_sec;
tsp->tv_nsec= (count % cycles_per_sec) * NS_PER_SEC / cycles_per_sec;

return 0;
}
#endif

/* initialize timer */

void sb_timer_init(sb_timer_t *t)
Expand Down
11 changes: 11 additions & 0 deletions src/sb_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
(a.tv_nsec - b.tv_nsec))

/* Wrapper over various *gettime* functions */

#ifdef __QNX__
# define SB_GETTIME(tsp) sb_timer_cycle_timer(tsp)
#else
#ifdef HAVE_CLOCK_GETTIME
# define SB_GETTIME(tsp) clock_gettime(CLOCK_MONOTONIC, tsp)
#else
Expand All @@ -73,6 +77,7 @@
(tsp)->tv_nsec = tv.tv_usec * 1000; \
} while (0)
#endif
#endif

typedef enum {TIMER_UNINITIALIZED, TIMER_INITIALIZED, TIMER_STOPPED, \
TIMER_RUNNING} timer_state_t;
Expand Down Expand Up @@ -102,6 +107,12 @@ static inline int sb_nanosleep(uint64_t ns)
return nanosleep(&ts, NULL);
}


/* Create Clock Cycle timer */
#ifdef __QNX__
int sb_timer_cycle_timer(struct timespec *tsp);
#endif

/* timer control functions */

/* Initialize timer */
Expand Down
3 changes: 3 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ install_test_files:
done \
done

@if test "${QNXENV}" = "true"; then \
$(INSTALL_DATA) $(PWD)/include/config.sh $(testdir)/include/config.sh; \
fi
dist-hook:
$(MAKE) INSTALL_TO_DIR="$(distdir)" install_test_files

Expand Down
2 changes: 1 addition & 1 deletion tests/t/api_rand.t
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ GH-96: sb_rand_uniq(1, oltp_table_size) generate duplicate value
> end
> EOF

$ sysbench $SB_ARGS --events=100000 $CRAMTMP/api_rand_uniq.lua run |
$ sysbench $SB_ARGS --events=100000 --time=9999 $CRAMTMP/api_rand_uniq.lua run |
> sort -n | uniq | wc -l | sed -e 's/ //g'
100000
34 changes: 26 additions & 8 deletions third_party/concurrency_kit/ck/configure
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
# SUCH DAMAGE.
#

if test ${QNXENV} = "true"; then
SYSTEM="QNX"
case $host_cpu in
aarch64)
PLATFORM="aarch64"
;;
x86_64)
PLATFORM="x86_64"
;;
esac
fi

REQUIRE_HEADER="stdbool.h stddef.h stdint.h string.h"

EXIT_SUCCESS=0
Expand Down Expand Up @@ -69,6 +81,8 @@ assert()
elif test "$#" -eq 3; then
fail=$3
print=echo
elif "${QNXENV}" = "true" && test "$#" -gt 0; then
print=echo
else
echo "Usage: assert <test> <fail string> or assert <test> <success string> <fail string>" 1>&2
exit $EXIT_FAILURE
Expand Down Expand Up @@ -570,12 +584,16 @@ else
fi

printf "Finding suitable compiler........"
if test ! -x "${CC}"; then
CC=`pathsearch "${CC:-cc}"`
if test -z "$CC" -o ! -x "$CC"; then
CC=`pathsearch "${CC:-gcc}"`

if test ${QNXENV} != "true"; then
if test ! -x "${CC}"; then
CC=`pathsearch "${CC:-cc}"`
if test -z "$CC" -o ! -x "$CC"; then
CC=`pathsearch "${CC:-gcc}"`
fi
fi
fi

assert "$CC" "not found"

cat << EOF > .1.c
Expand Down Expand Up @@ -611,18 +629,18 @@ COMPILER=`./.1 2> /dev/null`
r=$?
rm -f .1.c .1

if test "$r" -ne 0; then
assert "" "update compiler"
if test ${QNXENV} != "true" && test "$r" -ne 0; then
assert "" "update compiler"
else
echo "success [$CC]"
echo "success [$CC]"
fi

if test "$COMPILER" = "suncc"; then
LD=/bin/ld
LDFLAGS="-G -z text -h libck.so.$VERSION_MAJOR $LDFLAGS"
CFLAGS="-xO5 $CFLAGS"
PTHREAD_CFLAGS="-mt -lpthread"
elif test "$COMPILER" = "gcc" || test "$COMPILER" = "clang" || test "$COMPILER" = "mingw32" || test "$COMPILER" = "mingw64"; then
elif test ${QNXENV} = "true" || test "$COMPILER" = "gcc" || test "$COMPILER" = "clang" || test "$COMPILER" = "mingw32" || test "$COMPILER" = "mingw64"; then
LD=$CC
SONAME="$LDNAME_MAJOR"
if test "$SYSTEM" = "darwin"; then
Expand Down
19 changes: 15 additions & 4 deletions third_party/luajit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,21 @@ $(builddir)/lib/libluajit-5.1.a:
mkdir tmp
tar -C $(srcdir) -cf - luajit | tar -xf - -C tmp/
chmod -R u+w tmp
$(MAKE) -C tmp/luajit \
PREFIX=$(abs_top_builddir)/third_party/luajit \
INSTALL_INC=$(abs_top_builddir)/third_party/luajit/inc \
install
@if test ${QNXENV} == true; \
then \
$(MAKE) -C tmp/luajit \
TARGET=POSIX \
CC="gcc" \
PREFIX=$(abs_top_builddir)/third_party/luajit \
INSTALL_INC=$(abs_top_builddir)/third_party/luajit/inc \
CROSS=$(host_alias)- \
install; \
else \
$(MAKE) -C tmp/luajit \
PREFIX=$(abs_top_builddir)/third_party/luajit \
INSTALL_INC=$(abs_top_builddir)/third_party/luajit/inc \
install; \
fi

clean-local:
rm -rf tmp bin inc lib share
29 changes: 27 additions & 2 deletions third_party/luajit/luajit/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,13 @@ ASOPTIONS= $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS)
CCOPTIONS= $(CCDEBUG) $(ASOPTIONS)
LDOPTIONS= $(CCDEBUG) $(LDFLAGS)

HOST_CC= $(CC)
HOST_RM?= rm -f
HOST_CC ?= $(CC)
HOST_RM ?= rm -f

ifeq ($(OS),QNX)
HOST_CC = qcc
endif

# If left blank, minilua is built and used. You can supply an installed
# copy of (plain) Lua 5.1 or 5.2, plus Lua BitOp. E.g. with: HOST_LUA=lua
HOST_LUA=
Expand Down Expand Up @@ -639,7 +644,11 @@ depend:

$(MINILUA_T): $(MINILUA_O)
$(E) "HOSTLINK $@"
ifeq ($(QNXENV), true)
$(Q)$(HOST_CC) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS)
else
$(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS)
endif

host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) $(DASM_DIR)/*.lua lj_arch.h lua.h luaconf.h
$(E) "DYNASM $@"
Expand All @@ -649,7 +658,11 @@ host/buildvm.o: $(DASM_DIR)/dasm_*.h

$(BUILDVM_T): $(BUILDVM_O)
$(E) "HOSTLINK $@"
ifeq ($(QNXENV), true)
$(Q)$(HOST_CC) -o $@ $(BUILDVM_O) $(HOST_ALIBS)
else
$(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS)
endif

$(LJVM_BOUT): $(BUILDVM_T)
$(E) "BUILDVM $@"
Expand Down Expand Up @@ -699,7 +712,11 @@ $(LUAJIT_O):

$(HOST_O): %.o: %.c
$(E) "HOSTCC $@"
ifeq ($(QNXENV), true)
$(Q)$(HOST_CC) $(filter-out -mlittle-endian, $(HOST_ACFLAGS)) -c -o $@ $<
else
$(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $<
endif

include Makefile.dep

Expand All @@ -714,12 +731,20 @@ $(LUAJIT_A): $(LJVMCORE_O)
# The dependency on _O, but linking with _DYNO is intentional.
$(LUAJIT_SO): $(LJVMCORE_O)
$(E) "DYNLINK $@"
ifeq ($(QNXENV), true)
$(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(filter-out -ldl, $(TARGET_ALIBS))
else
$(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS)
endif
$(Q)$(TARGET_STRIP) $@

$(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP)
$(E) "LINK $@"
ifeq ($(QNXENV), true)
$(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(filter-out -ldl, $(TARGET_ALIBS))
else
$(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS)
endif
$(Q)$(TARGET_STRIP) $@
$(E) "OK Successfully built LuaJIT"

Expand Down