diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.inl b/invertedlogic/iLPlatform/iLAtomics.inl new file mode 100644 index 0000000..37899eb --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.inl @@ -0,0 +1,34 @@ +#include "iLPlatform.h" +#include "iLOperatingSystem.h" + + +// Returns the original value pointed to by a_ptr +// If that value is the same as a_comparand, then *a_ptr is assigned a_val +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int32_t ret = *a_ptr; + OSAtomicCompareAndSwap32(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange64(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int64_t ret = *a_ptr; + OSAtomicCompareAndSwap64(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.inl b/invertedlogic/iLPlatform/iLAtomics.inl new file mode 100644 index 0000000..37899eb --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.inl @@ -0,0 +1,34 @@ +#include "iLPlatform.h" +#include "iLOperatingSystem.h" + + +// Returns the original value pointed to by a_ptr +// If that value is the same as a_comparand, then *a_ptr is assigned a_val +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int32_t ret = *a_ptr; + OSAtomicCompareAndSwap32(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange64(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int64_t ret = *a_ptr; + OSAtomicCompareAndSwap64(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + diff --git a/invertedlogic/iLPlatform/iLCompiler.h b/invertedlogic/iLPlatform/iLCompiler.h new file mode 100644 index 0000000..4332dbd --- /dev/null +++ b/invertedlogic/iLPlatform/iLCompiler.h @@ -0,0 +1,23 @@ +#ifndef IL_COMPILER_H +#define IL_COMPILER_H + + +#if defined(MSVC) + +# define IL_COMPILER_MSVC 1 +# define IL_COMPILER "MSVC" + +#elif defined(GCC) || defined(__GNUC__) + +# define IL_COMPILER_GCC 1 +# define IL_COMPILER "GCC" + +#else + +# error "Undetected compiler" + +#endif + + +#endif // IL_COMPILER_H + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.inl b/invertedlogic/iLPlatform/iLAtomics.inl new file mode 100644 index 0000000..37899eb --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.inl @@ -0,0 +1,34 @@ +#include "iLPlatform.h" +#include "iLOperatingSystem.h" + + +// Returns the original value pointed to by a_ptr +// If that value is the same as a_comparand, then *a_ptr is assigned a_val +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int32_t ret = *a_ptr; + OSAtomicCompareAndSwap32(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange64(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int64_t ret = *a_ptr; + OSAtomicCompareAndSwap64(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + diff --git a/invertedlogic/iLPlatform/iLCompiler.h b/invertedlogic/iLPlatform/iLCompiler.h new file mode 100644 index 0000000..4332dbd --- /dev/null +++ b/invertedlogic/iLPlatform/iLCompiler.h @@ -0,0 +1,23 @@ +#ifndef IL_COMPILER_H +#define IL_COMPILER_H + + +#if defined(MSVC) + +# define IL_COMPILER_MSVC 1 +# define IL_COMPILER "MSVC" + +#elif defined(GCC) || defined(__GNUC__) + +# define IL_COMPILER_GCC 1 +# define IL_COMPILER "GCC" + +#else + +# error "Undetected compiler" + +#endif + + +#endif // IL_COMPILER_H + diff --git a/invertedlogic/iLPlatform/iLOperatingSystem.h b/invertedlogic/iLPlatform/iLOperatingSystem.h new file mode 100644 index 0000000..c4dbb70 --- /dev/null +++ b/invertedlogic/iLPlatform/iLOperatingSystem.h @@ -0,0 +1,23 @@ +#ifndef IL_OPERATING_SYSTEM_H +#define IL_OPERATING_SYSTEM_H + + +#if defined(ANDROID) || defined(__ANDROID__) +# define IL_OPERATING_SYSTEM_ANDROID 1 +# define IL_OPERATING_SYSTEM "Android" +#elif defined(linux) || defined(__linux__) +# define IL_OPERATING_SYSTEM_LINUX 1 +# define IL_OPERATING_SYSTEM "Linux" +#elif defined(MACOSX) || (defined(__DARWIN__) && defined(__APPLE__)) +# define IL_OPERATING_SYSTEM_MACOSX 1 +# define IL_OPERATING_SYSTEM "MacOSX" +#elif defined(_WIN32) +# define IL_OPERATING_SYSTEM_WINDOWS 1 +# define IL_OPERATING_SYSTEM "Windows" +#else +# error "Undetected operating system" +#endif + + +#endif // IL_OPERATING_SYSTEM_H + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.inl b/invertedlogic/iLPlatform/iLAtomics.inl new file mode 100644 index 0000000..37899eb --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.inl @@ -0,0 +1,34 @@ +#include "iLPlatform.h" +#include "iLOperatingSystem.h" + + +// Returns the original value pointed to by a_ptr +// If that value is the same as a_comparand, then *a_ptr is assigned a_val +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int32_t ret = *a_ptr; + OSAtomicCompareAndSwap32(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange64(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int64_t ret = *a_ptr; + OSAtomicCompareAndSwap64(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + diff --git a/invertedlogic/iLPlatform/iLCompiler.h b/invertedlogic/iLPlatform/iLCompiler.h new file mode 100644 index 0000000..4332dbd --- /dev/null +++ b/invertedlogic/iLPlatform/iLCompiler.h @@ -0,0 +1,23 @@ +#ifndef IL_COMPILER_H +#define IL_COMPILER_H + + +#if defined(MSVC) + +# define IL_COMPILER_MSVC 1 +# define IL_COMPILER "MSVC" + +#elif defined(GCC) || defined(__GNUC__) + +# define IL_COMPILER_GCC 1 +# define IL_COMPILER "GCC" + +#else + +# error "Undetected compiler" + +#endif + + +#endif // IL_COMPILER_H + diff --git a/invertedlogic/iLPlatform/iLOperatingSystem.h b/invertedlogic/iLPlatform/iLOperatingSystem.h new file mode 100644 index 0000000..c4dbb70 --- /dev/null +++ b/invertedlogic/iLPlatform/iLOperatingSystem.h @@ -0,0 +1,23 @@ +#ifndef IL_OPERATING_SYSTEM_H +#define IL_OPERATING_SYSTEM_H + + +#if defined(ANDROID) || defined(__ANDROID__) +# define IL_OPERATING_SYSTEM_ANDROID 1 +# define IL_OPERATING_SYSTEM "Android" +#elif defined(linux) || defined(__linux__) +# define IL_OPERATING_SYSTEM_LINUX 1 +# define IL_OPERATING_SYSTEM "Linux" +#elif defined(MACOSX) || (defined(__DARWIN__) && defined(__APPLE__)) +# define IL_OPERATING_SYSTEM_MACOSX 1 +# define IL_OPERATING_SYSTEM "MacOSX" +#elif defined(_WIN32) +# define IL_OPERATING_SYSTEM_WINDOWS 1 +# define IL_OPERATING_SYSTEM "Windows" +#else +# error "Undetected operating system" +#endif + + +#endif // IL_OPERATING_SYSTEM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform b/invertedlogic/iLPlatform/iLPlatform new file mode 100755 index 0000000..2329aa2 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform Binary files differ diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.inl b/invertedlogic/iLPlatform/iLAtomics.inl new file mode 100644 index 0000000..37899eb --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.inl @@ -0,0 +1,34 @@ +#include "iLPlatform.h" +#include "iLOperatingSystem.h" + + +// Returns the original value pointed to by a_ptr +// If that value is the same as a_comparand, then *a_ptr is assigned a_val +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int32_t ret = *a_ptr; + OSAtomicCompareAndSwap32(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange64(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int64_t ret = *a_ptr; + OSAtomicCompareAndSwap64(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + diff --git a/invertedlogic/iLPlatform/iLCompiler.h b/invertedlogic/iLPlatform/iLCompiler.h new file mode 100644 index 0000000..4332dbd --- /dev/null +++ b/invertedlogic/iLPlatform/iLCompiler.h @@ -0,0 +1,23 @@ +#ifndef IL_COMPILER_H +#define IL_COMPILER_H + + +#if defined(MSVC) + +# define IL_COMPILER_MSVC 1 +# define IL_COMPILER "MSVC" + +#elif defined(GCC) || defined(__GNUC__) + +# define IL_COMPILER_GCC 1 +# define IL_COMPILER "GCC" + +#else + +# error "Undetected compiler" + +#endif + + +#endif // IL_COMPILER_H + diff --git a/invertedlogic/iLPlatform/iLOperatingSystem.h b/invertedlogic/iLPlatform/iLOperatingSystem.h new file mode 100644 index 0000000..c4dbb70 --- /dev/null +++ b/invertedlogic/iLPlatform/iLOperatingSystem.h @@ -0,0 +1,23 @@ +#ifndef IL_OPERATING_SYSTEM_H +#define IL_OPERATING_SYSTEM_H + + +#if defined(ANDROID) || defined(__ANDROID__) +# define IL_OPERATING_SYSTEM_ANDROID 1 +# define IL_OPERATING_SYSTEM "Android" +#elif defined(linux) || defined(__linux__) +# define IL_OPERATING_SYSTEM_LINUX 1 +# define IL_OPERATING_SYSTEM "Linux" +#elif defined(MACOSX) || (defined(__DARWIN__) && defined(__APPLE__)) +# define IL_OPERATING_SYSTEM_MACOSX 1 +# define IL_OPERATING_SYSTEM "MacOSX" +#elif defined(_WIN32) +# define IL_OPERATING_SYSTEM_WINDOWS 1 +# define IL_OPERATING_SYSTEM "Windows" +#else +# error "Undetected operating system" +#endif + + +#endif // IL_OPERATING_SYSTEM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform b/invertedlogic/iLPlatform/iLPlatform new file mode 100755 index 0000000..2329aa2 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform Binary files differ diff --git a/invertedlogic/iLPlatform/iLPlatform.h b/invertedlogic/iLPlatform/iLPlatform.h new file mode 100644 index 0000000..de4edb6 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.h @@ -0,0 +1,17 @@ +#ifndef IL_PLATFORM_H +#define IL_PLATFORM_H + + +#if defined(_WIN32) +# define IL_PLATFORM_WINDOWS 1 +# define IL_PLATFORM "Windows" +#elif defined(unix) || defined(__unix__) +# define IL_PLATFORM_UNIX 1 +# define IL_PLATFORM "Unix" +#else +# error "Undetected platform" +#endif + + +#endif // IL_PLATFORM_H + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.inl b/invertedlogic/iLPlatform/iLAtomics.inl new file mode 100644 index 0000000..37899eb --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.inl @@ -0,0 +1,34 @@ +#include "iLPlatform.h" +#include "iLOperatingSystem.h" + + +// Returns the original value pointed to by a_ptr +// If that value is the same as a_comparand, then *a_ptr is assigned a_val +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int32_t ret = *a_ptr; + OSAtomicCompareAndSwap32(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange64(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int64_t ret = *a_ptr; + OSAtomicCompareAndSwap64(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + diff --git a/invertedlogic/iLPlatform/iLCompiler.h b/invertedlogic/iLPlatform/iLCompiler.h new file mode 100644 index 0000000..4332dbd --- /dev/null +++ b/invertedlogic/iLPlatform/iLCompiler.h @@ -0,0 +1,23 @@ +#ifndef IL_COMPILER_H +#define IL_COMPILER_H + + +#if defined(MSVC) + +# define IL_COMPILER_MSVC 1 +# define IL_COMPILER "MSVC" + +#elif defined(GCC) || defined(__GNUC__) + +# define IL_COMPILER_GCC 1 +# define IL_COMPILER "GCC" + +#else + +# error "Undetected compiler" + +#endif + + +#endif // IL_COMPILER_H + diff --git a/invertedlogic/iLPlatform/iLOperatingSystem.h b/invertedlogic/iLPlatform/iLOperatingSystem.h new file mode 100644 index 0000000..c4dbb70 --- /dev/null +++ b/invertedlogic/iLPlatform/iLOperatingSystem.h @@ -0,0 +1,23 @@ +#ifndef IL_OPERATING_SYSTEM_H +#define IL_OPERATING_SYSTEM_H + + +#if defined(ANDROID) || defined(__ANDROID__) +# define IL_OPERATING_SYSTEM_ANDROID 1 +# define IL_OPERATING_SYSTEM "Android" +#elif defined(linux) || defined(__linux__) +# define IL_OPERATING_SYSTEM_LINUX 1 +# define IL_OPERATING_SYSTEM "Linux" +#elif defined(MACOSX) || (defined(__DARWIN__) && defined(__APPLE__)) +# define IL_OPERATING_SYSTEM_MACOSX 1 +# define IL_OPERATING_SYSTEM "MacOSX" +#elif defined(_WIN32) +# define IL_OPERATING_SYSTEM_WINDOWS 1 +# define IL_OPERATING_SYSTEM "Windows" +#else +# error "Undetected operating system" +#endif + + +#endif // IL_OPERATING_SYSTEM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform b/invertedlogic/iLPlatform/iLPlatform new file mode 100755 index 0000000..2329aa2 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform Binary files differ diff --git a/invertedlogic/iLPlatform/iLPlatform.h b/invertedlogic/iLPlatform/iLPlatform.h new file mode 100644 index 0000000..de4edb6 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.h @@ -0,0 +1,17 @@ +#ifndef IL_PLATFORM_H +#define IL_PLATFORM_H + + +#if defined(_WIN32) +# define IL_PLATFORM_WINDOWS 1 +# define IL_PLATFORM "Windows" +#elif defined(unix) || defined(__unix__) +# define IL_PLATFORM_UNIX 1 +# define IL_PLATFORM "Unix" +#else +# error "Undetected platform" +#endif + + +#endif // IL_PLATFORM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform.pro b/invertedlogic/iLPlatform/iLPlatform.pro new file mode 100644 index 0000000..67da2f7 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.pro @@ -0,0 +1,6 @@ + +TEMPLATE = app + +SOURCES += test.cpp + + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.inl b/invertedlogic/iLPlatform/iLAtomics.inl new file mode 100644 index 0000000..37899eb --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.inl @@ -0,0 +1,34 @@ +#include "iLPlatform.h" +#include "iLOperatingSystem.h" + + +// Returns the original value pointed to by a_ptr +// If that value is the same as a_comparand, then *a_ptr is assigned a_val +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int32_t ret = *a_ptr; + OSAtomicCompareAndSwap32(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange64(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int64_t ret = *a_ptr; + OSAtomicCompareAndSwap64(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + diff --git a/invertedlogic/iLPlatform/iLCompiler.h b/invertedlogic/iLPlatform/iLCompiler.h new file mode 100644 index 0000000..4332dbd --- /dev/null +++ b/invertedlogic/iLPlatform/iLCompiler.h @@ -0,0 +1,23 @@ +#ifndef IL_COMPILER_H +#define IL_COMPILER_H + + +#if defined(MSVC) + +# define IL_COMPILER_MSVC 1 +# define IL_COMPILER "MSVC" + +#elif defined(GCC) || defined(__GNUC__) + +# define IL_COMPILER_GCC 1 +# define IL_COMPILER "GCC" + +#else + +# error "Undetected compiler" + +#endif + + +#endif // IL_COMPILER_H + diff --git a/invertedlogic/iLPlatform/iLOperatingSystem.h b/invertedlogic/iLPlatform/iLOperatingSystem.h new file mode 100644 index 0000000..c4dbb70 --- /dev/null +++ b/invertedlogic/iLPlatform/iLOperatingSystem.h @@ -0,0 +1,23 @@ +#ifndef IL_OPERATING_SYSTEM_H +#define IL_OPERATING_SYSTEM_H + + +#if defined(ANDROID) || defined(__ANDROID__) +# define IL_OPERATING_SYSTEM_ANDROID 1 +# define IL_OPERATING_SYSTEM "Android" +#elif defined(linux) || defined(__linux__) +# define IL_OPERATING_SYSTEM_LINUX 1 +# define IL_OPERATING_SYSTEM "Linux" +#elif defined(MACOSX) || (defined(__DARWIN__) && defined(__APPLE__)) +# define IL_OPERATING_SYSTEM_MACOSX 1 +# define IL_OPERATING_SYSTEM "MacOSX" +#elif defined(_WIN32) +# define IL_OPERATING_SYSTEM_WINDOWS 1 +# define IL_OPERATING_SYSTEM "Windows" +#else +# error "Undetected operating system" +#endif + + +#endif // IL_OPERATING_SYSTEM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform b/invertedlogic/iLPlatform/iLPlatform new file mode 100755 index 0000000..2329aa2 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform Binary files differ diff --git a/invertedlogic/iLPlatform/iLPlatform.h b/invertedlogic/iLPlatform/iLPlatform.h new file mode 100644 index 0000000..de4edb6 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.h @@ -0,0 +1,17 @@ +#ifndef IL_PLATFORM_H +#define IL_PLATFORM_H + + +#if defined(_WIN32) +# define IL_PLATFORM_WINDOWS 1 +# define IL_PLATFORM "Windows" +#elif defined(unix) || defined(__unix__) +# define IL_PLATFORM_UNIX 1 +# define IL_PLATFORM "Unix" +#else +# error "Undetected platform" +#endif + + +#endif // IL_PLATFORM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform.pro b/invertedlogic/iLPlatform/iLPlatform.pro new file mode 100644 index 0000000..67da2f7 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.pro @@ -0,0 +1,6 @@ + +TEMPLATE = app + +SOURCES += test.cpp + + diff --git a/invertedlogic/iLPlatform/iLSemaphore.h b/invertedlogic/iLPlatform/iLSemaphore.h new file mode 100644 index 0000000..42df4e4 --- /dev/null +++ b/invertedlogic/iLPlatform/iLSemaphore.h @@ -0,0 +1,119 @@ +#include +#include /* For O_* constants */ +#include /* For mode constants */ +#include + + +#if 1 + +typedef pthread_mutex_t iLMutex; +typedef sem_t iLSemaphore; + +static inline void iLMutex_Create(iLMutex* a_mutex) +{ + pthread_mutex_init(a_mutex, NULL); +} + +static inline void iLMutex_Lock(iLMutex* a_mutex) +{ + pthread_mutex_lock(a_mutex); +} + +static inline void iLMutex_Unlock(iLMutex* a_mutex) +{ + pthread_mutex_unlock(a_mutex); +} + +static inline void iLSemaphore_Create(iLSemaphore* a_sem, uint32_t a_initCount, uint32_t a_maxCount) +{ + a_sem = sem_open("/sem", O_CREAT, S_IRWXU, a_initCount); +} + +static inline void iLSemaphore_Wait(iLSemaphore* a_sem) +{ + sem_wait(a_sem); +} + +static inline void iLSemaphore_Signal(iLSemaphore* a_sem, uint32_t a_count) +{ + for (int i = 0; i < a_count; i++) + sem_post(a_sem); +} + +#else + +typedef uint32_t iLMutex; + +static inline void iLMutex_Create(iLMutex* a_mutex) +{ + *a_mutex = 0; +} + +static inline void iLMutex_Lock(iLMutex* a_mutex) +{ + int spinCount = 0; + while (__sync_lock_test_and_set(a_mutex, 1) == 1) + { + spinCount++; + if (spinCount > 1000000) + { + spinCount = 0; + pthread_yield(); + } + } +} + +static inline void iLMutex_Unlock(iLMutex* a_mutex) +{ + __sync_lock_release(a_mutex); +} + +struct iLSemaphore +{ + uint32_t count; + uint32_t maxCount; + uint32_t waitCount; + iLMutex mutex; + pthread_cond_t cond; +}; + +static inline void iLSemaphore_Create(iLSemaphore* a_sem, uint32_t a_initCount, iLMutex* a_maxCount) +{ + a_sem->count = a_initCount; + a_sem->maxCount = a_maxCount; + a_sem->waitCount = 0; + iLMutex_Create(&a_sem->mutex); + pthread_cond_init(&a_sem->cond, NULL); +} + +static inline void iLSemaphore_Wait(iLSemaphore* a_sem) +{ + iLMutex_Lock(&a_sem->mutex); + while(a_sem->count == 0) + { + ++a_sem->waitCount; + pthread_cond_wait(&a_sem->cond, &a_sem->mutex); + --a_sem->waitCount; + } + --a_sem->count; + iLMutex_Unlock(&a_sem->mutex); +} + +static inline void iLSemaphore_Signal(iLSemaphore* a_sem, uint32_t a_count) +{ + iLMutex_Lock(&a_sem->mutex); + a_sem->count += a_count; + if (a_sem->count > a_sem->maxCount) + { + a_sem->count = a_sem->maxCount; + } + if (a_sem->waitCount > 0) + { + pthread_cond_signal(&a_sem->cond); + } + iLMutex_Unlock(&a_sem->mutex); +} + +#endif + + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.inl b/invertedlogic/iLPlatform/iLAtomics.inl new file mode 100644 index 0000000..37899eb --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.inl @@ -0,0 +1,34 @@ +#include "iLPlatform.h" +#include "iLOperatingSystem.h" + + +// Returns the original value pointed to by a_ptr +// If that value is the same as a_comparand, then *a_ptr is assigned a_val +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int32_t ret = *a_ptr; + OSAtomicCompareAndSwap32(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange64(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int64_t ret = *a_ptr; + OSAtomicCompareAndSwap64(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + diff --git a/invertedlogic/iLPlatform/iLCompiler.h b/invertedlogic/iLPlatform/iLCompiler.h new file mode 100644 index 0000000..4332dbd --- /dev/null +++ b/invertedlogic/iLPlatform/iLCompiler.h @@ -0,0 +1,23 @@ +#ifndef IL_COMPILER_H +#define IL_COMPILER_H + + +#if defined(MSVC) + +# define IL_COMPILER_MSVC 1 +# define IL_COMPILER "MSVC" + +#elif defined(GCC) || defined(__GNUC__) + +# define IL_COMPILER_GCC 1 +# define IL_COMPILER "GCC" + +#else + +# error "Undetected compiler" + +#endif + + +#endif // IL_COMPILER_H + diff --git a/invertedlogic/iLPlatform/iLOperatingSystem.h b/invertedlogic/iLPlatform/iLOperatingSystem.h new file mode 100644 index 0000000..c4dbb70 --- /dev/null +++ b/invertedlogic/iLPlatform/iLOperatingSystem.h @@ -0,0 +1,23 @@ +#ifndef IL_OPERATING_SYSTEM_H +#define IL_OPERATING_SYSTEM_H + + +#if defined(ANDROID) || defined(__ANDROID__) +# define IL_OPERATING_SYSTEM_ANDROID 1 +# define IL_OPERATING_SYSTEM "Android" +#elif defined(linux) || defined(__linux__) +# define IL_OPERATING_SYSTEM_LINUX 1 +# define IL_OPERATING_SYSTEM "Linux" +#elif defined(MACOSX) || (defined(__DARWIN__) && defined(__APPLE__)) +# define IL_OPERATING_SYSTEM_MACOSX 1 +# define IL_OPERATING_SYSTEM "MacOSX" +#elif defined(_WIN32) +# define IL_OPERATING_SYSTEM_WINDOWS 1 +# define IL_OPERATING_SYSTEM "Windows" +#else +# error "Undetected operating system" +#endif + + +#endif // IL_OPERATING_SYSTEM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform b/invertedlogic/iLPlatform/iLPlatform new file mode 100755 index 0000000..2329aa2 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform Binary files differ diff --git a/invertedlogic/iLPlatform/iLPlatform.h b/invertedlogic/iLPlatform/iLPlatform.h new file mode 100644 index 0000000..de4edb6 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.h @@ -0,0 +1,17 @@ +#ifndef IL_PLATFORM_H +#define IL_PLATFORM_H + + +#if defined(_WIN32) +# define IL_PLATFORM_WINDOWS 1 +# define IL_PLATFORM "Windows" +#elif defined(unix) || defined(__unix__) +# define IL_PLATFORM_UNIX 1 +# define IL_PLATFORM "Unix" +#else +# error "Undetected platform" +#endif + + +#endif // IL_PLATFORM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform.pro b/invertedlogic/iLPlatform/iLPlatform.pro new file mode 100644 index 0000000..67da2f7 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.pro @@ -0,0 +1,6 @@ + +TEMPLATE = app + +SOURCES += test.cpp + + diff --git a/invertedlogic/iLPlatform/iLSemaphore.h b/invertedlogic/iLPlatform/iLSemaphore.h new file mode 100644 index 0000000..42df4e4 --- /dev/null +++ b/invertedlogic/iLPlatform/iLSemaphore.h @@ -0,0 +1,119 @@ +#include +#include /* For O_* constants */ +#include /* For mode constants */ +#include + + +#if 1 + +typedef pthread_mutex_t iLMutex; +typedef sem_t iLSemaphore; + +static inline void iLMutex_Create(iLMutex* a_mutex) +{ + pthread_mutex_init(a_mutex, NULL); +} + +static inline void iLMutex_Lock(iLMutex* a_mutex) +{ + pthread_mutex_lock(a_mutex); +} + +static inline void iLMutex_Unlock(iLMutex* a_mutex) +{ + pthread_mutex_unlock(a_mutex); +} + +static inline void iLSemaphore_Create(iLSemaphore* a_sem, uint32_t a_initCount, uint32_t a_maxCount) +{ + a_sem = sem_open("/sem", O_CREAT, S_IRWXU, a_initCount); +} + +static inline void iLSemaphore_Wait(iLSemaphore* a_sem) +{ + sem_wait(a_sem); +} + +static inline void iLSemaphore_Signal(iLSemaphore* a_sem, uint32_t a_count) +{ + for (int i = 0; i < a_count; i++) + sem_post(a_sem); +} + +#else + +typedef uint32_t iLMutex; + +static inline void iLMutex_Create(iLMutex* a_mutex) +{ + *a_mutex = 0; +} + +static inline void iLMutex_Lock(iLMutex* a_mutex) +{ + int spinCount = 0; + while (__sync_lock_test_and_set(a_mutex, 1) == 1) + { + spinCount++; + if (spinCount > 1000000) + { + spinCount = 0; + pthread_yield(); + } + } +} + +static inline void iLMutex_Unlock(iLMutex* a_mutex) +{ + __sync_lock_release(a_mutex); +} + +struct iLSemaphore +{ + uint32_t count; + uint32_t maxCount; + uint32_t waitCount; + iLMutex mutex; + pthread_cond_t cond; +}; + +static inline void iLSemaphore_Create(iLSemaphore* a_sem, uint32_t a_initCount, iLMutex* a_maxCount) +{ + a_sem->count = a_initCount; + a_sem->maxCount = a_maxCount; + a_sem->waitCount = 0; + iLMutex_Create(&a_sem->mutex); + pthread_cond_init(&a_sem->cond, NULL); +} + +static inline void iLSemaphore_Wait(iLSemaphore* a_sem) +{ + iLMutex_Lock(&a_sem->mutex); + while(a_sem->count == 0) + { + ++a_sem->waitCount; + pthread_cond_wait(&a_sem->cond, &a_sem->mutex); + --a_sem->waitCount; + } + --a_sem->count; + iLMutex_Unlock(&a_sem->mutex); +} + +static inline void iLSemaphore_Signal(iLSemaphore* a_sem, uint32_t a_count) +{ + iLMutex_Lock(&a_sem->mutex); + a_sem->count += a_count; + if (a_sem->count > a_sem->maxCount) + { + a_sem->count = a_sem->maxCount; + } + if (a_sem->waitCount > 0) + { + pthread_cond_signal(&a_sem->cond); + } + iLMutex_Unlock(&a_sem->mutex); +} + +#endif + + diff --git a/invertedlogic/iLPlatform/iLThreads.h b/invertedlogic/iLPlatform/iLThreads.h new file mode 100644 index 0000000..6d1b20d --- /dev/null +++ b/invertedlogic/iLPlatform/iLThreads.h @@ -0,0 +1,21 @@ +#ifndef IL_THREAD_H +#define IL_THREAD_H + + +#include "iLTypes.h" + + +typedef iLResult (*iLThreadProc)(void); + + +static inline iLResult iLThread_Create(iLThread* a_thread, iLThreadProc a_proc); +static inline iLResult iLThread_Destroy(iLThread* a_thread); +static inline iLResult iLThread_GetCurrent(iLThread* a_thread); +static inline iLResult iLThread_Yield(); + + +#include "iLThreads.inl" + + +#endif // IL_THREAD_H + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.inl b/invertedlogic/iLPlatform/iLAtomics.inl new file mode 100644 index 0000000..37899eb --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.inl @@ -0,0 +1,34 @@ +#include "iLPlatform.h" +#include "iLOperatingSystem.h" + + +// Returns the original value pointed to by a_ptr +// If that value is the same as a_comparand, then *a_ptr is assigned a_val +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int32_t ret = *a_ptr; + OSAtomicCompareAndSwap32(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange64(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int64_t ret = *a_ptr; + OSAtomicCompareAndSwap64(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + diff --git a/invertedlogic/iLPlatform/iLCompiler.h b/invertedlogic/iLPlatform/iLCompiler.h new file mode 100644 index 0000000..4332dbd --- /dev/null +++ b/invertedlogic/iLPlatform/iLCompiler.h @@ -0,0 +1,23 @@ +#ifndef IL_COMPILER_H +#define IL_COMPILER_H + + +#if defined(MSVC) + +# define IL_COMPILER_MSVC 1 +# define IL_COMPILER "MSVC" + +#elif defined(GCC) || defined(__GNUC__) + +# define IL_COMPILER_GCC 1 +# define IL_COMPILER "GCC" + +#else + +# error "Undetected compiler" + +#endif + + +#endif // IL_COMPILER_H + diff --git a/invertedlogic/iLPlatform/iLOperatingSystem.h b/invertedlogic/iLPlatform/iLOperatingSystem.h new file mode 100644 index 0000000..c4dbb70 --- /dev/null +++ b/invertedlogic/iLPlatform/iLOperatingSystem.h @@ -0,0 +1,23 @@ +#ifndef IL_OPERATING_SYSTEM_H +#define IL_OPERATING_SYSTEM_H + + +#if defined(ANDROID) || defined(__ANDROID__) +# define IL_OPERATING_SYSTEM_ANDROID 1 +# define IL_OPERATING_SYSTEM "Android" +#elif defined(linux) || defined(__linux__) +# define IL_OPERATING_SYSTEM_LINUX 1 +# define IL_OPERATING_SYSTEM "Linux" +#elif defined(MACOSX) || (defined(__DARWIN__) && defined(__APPLE__)) +# define IL_OPERATING_SYSTEM_MACOSX 1 +# define IL_OPERATING_SYSTEM "MacOSX" +#elif defined(_WIN32) +# define IL_OPERATING_SYSTEM_WINDOWS 1 +# define IL_OPERATING_SYSTEM "Windows" +#else +# error "Undetected operating system" +#endif + + +#endif // IL_OPERATING_SYSTEM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform b/invertedlogic/iLPlatform/iLPlatform new file mode 100755 index 0000000..2329aa2 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform Binary files differ diff --git a/invertedlogic/iLPlatform/iLPlatform.h b/invertedlogic/iLPlatform/iLPlatform.h new file mode 100644 index 0000000..de4edb6 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.h @@ -0,0 +1,17 @@ +#ifndef IL_PLATFORM_H +#define IL_PLATFORM_H + + +#if defined(_WIN32) +# define IL_PLATFORM_WINDOWS 1 +# define IL_PLATFORM "Windows" +#elif defined(unix) || defined(__unix__) +# define IL_PLATFORM_UNIX 1 +# define IL_PLATFORM "Unix" +#else +# error "Undetected platform" +#endif + + +#endif // IL_PLATFORM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform.pro b/invertedlogic/iLPlatform/iLPlatform.pro new file mode 100644 index 0000000..67da2f7 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.pro @@ -0,0 +1,6 @@ + +TEMPLATE = app + +SOURCES += test.cpp + + diff --git a/invertedlogic/iLPlatform/iLSemaphore.h b/invertedlogic/iLPlatform/iLSemaphore.h new file mode 100644 index 0000000..42df4e4 --- /dev/null +++ b/invertedlogic/iLPlatform/iLSemaphore.h @@ -0,0 +1,119 @@ +#include +#include /* For O_* constants */ +#include /* For mode constants */ +#include + + +#if 1 + +typedef pthread_mutex_t iLMutex; +typedef sem_t iLSemaphore; + +static inline void iLMutex_Create(iLMutex* a_mutex) +{ + pthread_mutex_init(a_mutex, NULL); +} + +static inline void iLMutex_Lock(iLMutex* a_mutex) +{ + pthread_mutex_lock(a_mutex); +} + +static inline void iLMutex_Unlock(iLMutex* a_mutex) +{ + pthread_mutex_unlock(a_mutex); +} + +static inline void iLSemaphore_Create(iLSemaphore* a_sem, uint32_t a_initCount, uint32_t a_maxCount) +{ + a_sem = sem_open("/sem", O_CREAT, S_IRWXU, a_initCount); +} + +static inline void iLSemaphore_Wait(iLSemaphore* a_sem) +{ + sem_wait(a_sem); +} + +static inline void iLSemaphore_Signal(iLSemaphore* a_sem, uint32_t a_count) +{ + for (int i = 0; i < a_count; i++) + sem_post(a_sem); +} + +#else + +typedef uint32_t iLMutex; + +static inline void iLMutex_Create(iLMutex* a_mutex) +{ + *a_mutex = 0; +} + +static inline void iLMutex_Lock(iLMutex* a_mutex) +{ + int spinCount = 0; + while (__sync_lock_test_and_set(a_mutex, 1) == 1) + { + spinCount++; + if (spinCount > 1000000) + { + spinCount = 0; + pthread_yield(); + } + } +} + +static inline void iLMutex_Unlock(iLMutex* a_mutex) +{ + __sync_lock_release(a_mutex); +} + +struct iLSemaphore +{ + uint32_t count; + uint32_t maxCount; + uint32_t waitCount; + iLMutex mutex; + pthread_cond_t cond; +}; + +static inline void iLSemaphore_Create(iLSemaphore* a_sem, uint32_t a_initCount, iLMutex* a_maxCount) +{ + a_sem->count = a_initCount; + a_sem->maxCount = a_maxCount; + a_sem->waitCount = 0; + iLMutex_Create(&a_sem->mutex); + pthread_cond_init(&a_sem->cond, NULL); +} + +static inline void iLSemaphore_Wait(iLSemaphore* a_sem) +{ + iLMutex_Lock(&a_sem->mutex); + while(a_sem->count == 0) + { + ++a_sem->waitCount; + pthread_cond_wait(&a_sem->cond, &a_sem->mutex); + --a_sem->waitCount; + } + --a_sem->count; + iLMutex_Unlock(&a_sem->mutex); +} + +static inline void iLSemaphore_Signal(iLSemaphore* a_sem, uint32_t a_count) +{ + iLMutex_Lock(&a_sem->mutex); + a_sem->count += a_count; + if (a_sem->count > a_sem->maxCount) + { + a_sem->count = a_sem->maxCount; + } + if (a_sem->waitCount > 0) + { + pthread_cond_signal(&a_sem->cond); + } + iLMutex_Unlock(&a_sem->mutex); +} + +#endif + + diff --git a/invertedlogic/iLPlatform/iLThreads.h b/invertedlogic/iLPlatform/iLThreads.h new file mode 100644 index 0000000..6d1b20d --- /dev/null +++ b/invertedlogic/iLPlatform/iLThreads.h @@ -0,0 +1,21 @@ +#ifndef IL_THREAD_H +#define IL_THREAD_H + + +#include "iLTypes.h" + + +typedef iLResult (*iLThreadProc)(void); + + +static inline iLResult iLThread_Create(iLThread* a_thread, iLThreadProc a_proc); +static inline iLResult iLThread_Destroy(iLThread* a_thread); +static inline iLResult iLThread_GetCurrent(iLThread* a_thread); +static inline iLResult iLThread_Yield(); + + +#include "iLThreads.inl" + + +#endif // IL_THREAD_H + diff --git a/invertedlogic/iLPlatform/iLThreads.inl b/invertedlogic/iLPlatform/iLThreads.inl new file mode 100644 index 0000000..ef633f0 --- /dev/null +++ b/invertedlogic/iLPlatform/iLThreads.inl @@ -0,0 +1,50 @@ + + +#if defined(IL_PLATFORM_UNIX) + + +static inline void *internalThreadStartProc(void *a_arg) +{ + return (void*)((iLThreadProc)a_arg)(); +} + + +static inline iLResult iLThread_Create(iLThread* a_thread, iLThreadProc a_proc) +{ + return ((pthread_create(a_thread, NULL, internalThreadStartProc, (void*)a_proc) == 0) ? iLR_OK : iLR_UnspecifiedFailure); +} + + +static inline iLResult iLThread_Destroy(iLThread* a_thread) +{ + if (a_thread == 0 || pthread_cancel(*a_thread) != 0) + return iLR_UnspecifiedFailure; + return (pthread_join(*a_thread, NULL) == 0) ? iLR_OK : iLR_UnspecifiedFailure; +} + + +static inline iLResult iLThread_GetCurrent(iLThread* a_thread) +{ + if (!a_thread) + return iLR_UnspecifiedFailure; + *a_thread = pthread_self(); + return iLR_OK; +} + + +static inline iLResult iLThread_Yield() +{ + pthread_yield(); + return iLR_OK; +} + + +#else + +// XXX TODO add windoes specific thread ode +# error "platform code not implemented" + +#endif + + + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.inl b/invertedlogic/iLPlatform/iLAtomics.inl new file mode 100644 index 0000000..37899eb --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.inl @@ -0,0 +1,34 @@ +#include "iLPlatform.h" +#include "iLOperatingSystem.h" + + +// Returns the original value pointed to by a_ptr +// If that value is the same as a_comparand, then *a_ptr is assigned a_val +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int32_t ret = *a_ptr; + OSAtomicCompareAndSwap32(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange64(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int64_t ret = *a_ptr; + OSAtomicCompareAndSwap64(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + diff --git a/invertedlogic/iLPlatform/iLCompiler.h b/invertedlogic/iLPlatform/iLCompiler.h new file mode 100644 index 0000000..4332dbd --- /dev/null +++ b/invertedlogic/iLPlatform/iLCompiler.h @@ -0,0 +1,23 @@ +#ifndef IL_COMPILER_H +#define IL_COMPILER_H + + +#if defined(MSVC) + +# define IL_COMPILER_MSVC 1 +# define IL_COMPILER "MSVC" + +#elif defined(GCC) || defined(__GNUC__) + +# define IL_COMPILER_GCC 1 +# define IL_COMPILER "GCC" + +#else + +# error "Undetected compiler" + +#endif + + +#endif // IL_COMPILER_H + diff --git a/invertedlogic/iLPlatform/iLOperatingSystem.h b/invertedlogic/iLPlatform/iLOperatingSystem.h new file mode 100644 index 0000000..c4dbb70 --- /dev/null +++ b/invertedlogic/iLPlatform/iLOperatingSystem.h @@ -0,0 +1,23 @@ +#ifndef IL_OPERATING_SYSTEM_H +#define IL_OPERATING_SYSTEM_H + + +#if defined(ANDROID) || defined(__ANDROID__) +# define IL_OPERATING_SYSTEM_ANDROID 1 +# define IL_OPERATING_SYSTEM "Android" +#elif defined(linux) || defined(__linux__) +# define IL_OPERATING_SYSTEM_LINUX 1 +# define IL_OPERATING_SYSTEM "Linux" +#elif defined(MACOSX) || (defined(__DARWIN__) && defined(__APPLE__)) +# define IL_OPERATING_SYSTEM_MACOSX 1 +# define IL_OPERATING_SYSTEM "MacOSX" +#elif defined(_WIN32) +# define IL_OPERATING_SYSTEM_WINDOWS 1 +# define IL_OPERATING_SYSTEM "Windows" +#else +# error "Undetected operating system" +#endif + + +#endif // IL_OPERATING_SYSTEM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform b/invertedlogic/iLPlatform/iLPlatform new file mode 100755 index 0000000..2329aa2 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform Binary files differ diff --git a/invertedlogic/iLPlatform/iLPlatform.h b/invertedlogic/iLPlatform/iLPlatform.h new file mode 100644 index 0000000..de4edb6 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.h @@ -0,0 +1,17 @@ +#ifndef IL_PLATFORM_H +#define IL_PLATFORM_H + + +#if defined(_WIN32) +# define IL_PLATFORM_WINDOWS 1 +# define IL_PLATFORM "Windows" +#elif defined(unix) || defined(__unix__) +# define IL_PLATFORM_UNIX 1 +# define IL_PLATFORM "Unix" +#else +# error "Undetected platform" +#endif + + +#endif // IL_PLATFORM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform.pro b/invertedlogic/iLPlatform/iLPlatform.pro new file mode 100644 index 0000000..67da2f7 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.pro @@ -0,0 +1,6 @@ + +TEMPLATE = app + +SOURCES += test.cpp + + diff --git a/invertedlogic/iLPlatform/iLSemaphore.h b/invertedlogic/iLPlatform/iLSemaphore.h new file mode 100644 index 0000000..42df4e4 --- /dev/null +++ b/invertedlogic/iLPlatform/iLSemaphore.h @@ -0,0 +1,119 @@ +#include +#include /* For O_* constants */ +#include /* For mode constants */ +#include + + +#if 1 + +typedef pthread_mutex_t iLMutex; +typedef sem_t iLSemaphore; + +static inline void iLMutex_Create(iLMutex* a_mutex) +{ + pthread_mutex_init(a_mutex, NULL); +} + +static inline void iLMutex_Lock(iLMutex* a_mutex) +{ + pthread_mutex_lock(a_mutex); +} + +static inline void iLMutex_Unlock(iLMutex* a_mutex) +{ + pthread_mutex_unlock(a_mutex); +} + +static inline void iLSemaphore_Create(iLSemaphore* a_sem, uint32_t a_initCount, uint32_t a_maxCount) +{ + a_sem = sem_open("/sem", O_CREAT, S_IRWXU, a_initCount); +} + +static inline void iLSemaphore_Wait(iLSemaphore* a_sem) +{ + sem_wait(a_sem); +} + +static inline void iLSemaphore_Signal(iLSemaphore* a_sem, uint32_t a_count) +{ + for (int i = 0; i < a_count; i++) + sem_post(a_sem); +} + +#else + +typedef uint32_t iLMutex; + +static inline void iLMutex_Create(iLMutex* a_mutex) +{ + *a_mutex = 0; +} + +static inline void iLMutex_Lock(iLMutex* a_mutex) +{ + int spinCount = 0; + while (__sync_lock_test_and_set(a_mutex, 1) == 1) + { + spinCount++; + if (spinCount > 1000000) + { + spinCount = 0; + pthread_yield(); + } + } +} + +static inline void iLMutex_Unlock(iLMutex* a_mutex) +{ + __sync_lock_release(a_mutex); +} + +struct iLSemaphore +{ + uint32_t count; + uint32_t maxCount; + uint32_t waitCount; + iLMutex mutex; + pthread_cond_t cond; +}; + +static inline void iLSemaphore_Create(iLSemaphore* a_sem, uint32_t a_initCount, iLMutex* a_maxCount) +{ + a_sem->count = a_initCount; + a_sem->maxCount = a_maxCount; + a_sem->waitCount = 0; + iLMutex_Create(&a_sem->mutex); + pthread_cond_init(&a_sem->cond, NULL); +} + +static inline void iLSemaphore_Wait(iLSemaphore* a_sem) +{ + iLMutex_Lock(&a_sem->mutex); + while(a_sem->count == 0) + { + ++a_sem->waitCount; + pthread_cond_wait(&a_sem->cond, &a_sem->mutex); + --a_sem->waitCount; + } + --a_sem->count; + iLMutex_Unlock(&a_sem->mutex); +} + +static inline void iLSemaphore_Signal(iLSemaphore* a_sem, uint32_t a_count) +{ + iLMutex_Lock(&a_sem->mutex); + a_sem->count += a_count; + if (a_sem->count > a_sem->maxCount) + { + a_sem->count = a_sem->maxCount; + } + if (a_sem->waitCount > 0) + { + pthread_cond_signal(&a_sem->cond); + } + iLMutex_Unlock(&a_sem->mutex); +} + +#endif + + diff --git a/invertedlogic/iLPlatform/iLThreads.h b/invertedlogic/iLPlatform/iLThreads.h new file mode 100644 index 0000000..6d1b20d --- /dev/null +++ b/invertedlogic/iLPlatform/iLThreads.h @@ -0,0 +1,21 @@ +#ifndef IL_THREAD_H +#define IL_THREAD_H + + +#include "iLTypes.h" + + +typedef iLResult (*iLThreadProc)(void); + + +static inline iLResult iLThread_Create(iLThread* a_thread, iLThreadProc a_proc); +static inline iLResult iLThread_Destroy(iLThread* a_thread); +static inline iLResult iLThread_GetCurrent(iLThread* a_thread); +static inline iLResult iLThread_Yield(); + + +#include "iLThreads.inl" + + +#endif // IL_THREAD_H + diff --git a/invertedlogic/iLPlatform/iLThreads.inl b/invertedlogic/iLPlatform/iLThreads.inl new file mode 100644 index 0000000..ef633f0 --- /dev/null +++ b/invertedlogic/iLPlatform/iLThreads.inl @@ -0,0 +1,50 @@ + + +#if defined(IL_PLATFORM_UNIX) + + +static inline void *internalThreadStartProc(void *a_arg) +{ + return (void*)((iLThreadProc)a_arg)(); +} + + +static inline iLResult iLThread_Create(iLThread* a_thread, iLThreadProc a_proc) +{ + return ((pthread_create(a_thread, NULL, internalThreadStartProc, (void*)a_proc) == 0) ? iLR_OK : iLR_UnspecifiedFailure); +} + + +static inline iLResult iLThread_Destroy(iLThread* a_thread) +{ + if (a_thread == 0 || pthread_cancel(*a_thread) != 0) + return iLR_UnspecifiedFailure; + return (pthread_join(*a_thread, NULL) == 0) ? iLR_OK : iLR_UnspecifiedFailure; +} + + +static inline iLResult iLThread_GetCurrent(iLThread* a_thread) +{ + if (!a_thread) + return iLR_UnspecifiedFailure; + *a_thread = pthread_self(); + return iLR_OK; +} + + +static inline iLResult iLThread_Yield() +{ + pthread_yield(); + return iLR_OK; +} + + +#else + +// XXX TODO add windoes specific thread ode +# error "platform code not implemented" + +#endif + + + diff --git a/invertedlogic/iLPlatform/iLTypes.h b/invertedlogic/iLPlatform/iLTypes.h new file mode 100644 index 0000000..a525182 --- /dev/null +++ b/invertedlogic/iLPlatform/iLTypes.h @@ -0,0 +1,35 @@ +#ifndef IL_TYPES_H +#define IL_TYPES_H + + +#include +#include "iLPlatform.h" + + +#if defined(IL_PLATFORM_UNIX) +#include +typedef pthread_t iLThread; +typedef int32_t* iLAtomic32; +typedef int64_t* iLAtomic64; +#elif defined(IL_PLATFORM_WINDOWS) +#include +typedef HANDLE iLThread; +typedef volatile int32_t* iLAtomic32; +typedef volatile int64_t* iLAtomic64; +#else +# error "Unsupported platform" +#endif + + +enum iLResult +{ + iLR_OK, + iLR_UnspecifiedFailure +}; + + +typedef iLResult (*iLThreadProc)(void); + + +#endif // IL_TYPES_H + diff --git a/invertedlogic/iLPlatform/Makefile b/invertedlogic/iLPlatform/Makefile new file mode 100644 index 0000000..3399c2c --- /dev/null +++ b/invertedlogic/iLPlatform/Makefile @@ -0,0 +1,221 @@ +############################################################################# +# Makefile for building: iLPlatform +# Generated by qmake (2.01a) (Qt 4.8.1) on: Sat Oct 19 00:55:00 2013 +# Project: iLPlatform.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile iLPlatform.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. +LINK = g++ +LFLAGS = -m64 -Wl,-O1 +LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = test.cpp +OBJECTS = test.o +DIST = /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + iLPlatform.pro +QMAKE_TARGET = iLPlatform +DESTDIR = +TARGET = iLPlatform + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: iLPlatform.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ + /usr/share/qt4/mkspecs/common/linux.conf \ + /usr/share/qt4/mkspecs/common/gcc-base.conf \ + /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ + /usr/share/qt4/mkspecs/common/g++-base.conf \ + /usr/share/qt4/mkspecs/common/g++-unix.conf \ + /usr/share/qt4/mkspecs/qconfig.pri \ + /usr/share/qt4/mkspecs/modules/qt_phonon.pri \ + /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /usr/share/qt4/mkspecs/features/qt_functions.prf \ + /usr/share/qt4/mkspecs/features/qt_config.prf \ + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /usr/share/qt4/mkspecs/features/default_pre.prf \ + /usr/share/qt4/mkspecs/features/release.prf \ + /usr/share/qt4/mkspecs/features/default_post.prf \ + /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ + /usr/share/qt4/mkspecs/features/warn_on.prf \ + /usr/share/qt4/mkspecs/features/qt.prf \ + /usr/share/qt4/mkspecs/features/unix/thread.prf \ + /usr/share/qt4/mkspecs/features/moc.prf \ + /usr/share/qt4/mkspecs/features/resources.prf \ + /usr/share/qt4/mkspecs/features/uic.prf \ + /usr/share/qt4/mkspecs/features/yacc.prf \ + /usr/share/qt4/mkspecs/features/lex.prf \ + /usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/x86_64-linux-gnu/libQtGui.prl \ + /usr/lib/x86_64-linux-gnu/libQtCore.prl + $(QMAKE) -o Makefile iLPlatform.pro +/usr/share/qt4/mkspecs/common/unix.conf: +/usr/share/qt4/mkspecs/common/linux.conf: +/usr/share/qt4/mkspecs/common/gcc-base.conf: +/usr/share/qt4/mkspecs/common/gcc-base-unix.conf: +/usr/share/qt4/mkspecs/common/g++-base.conf: +/usr/share/qt4/mkspecs/common/g++-unix.conf: +/usr/share/qt4/mkspecs/qconfig.pri: +/usr/share/qt4/mkspecs/modules/qt_phonon.pri: +/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/usr/share/qt4/mkspecs/features/qt_functions.prf: +/usr/share/qt4/mkspecs/features/qt_config.prf: +/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/usr/share/qt4/mkspecs/features/default_pre.prf: +/usr/share/qt4/mkspecs/features/release.prf: +/usr/share/qt4/mkspecs/features/default_post.prf: +/usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: +/usr/share/qt4/mkspecs/features/warn_on.prf: +/usr/share/qt4/mkspecs/features/qt.prf: +/usr/share/qt4/mkspecs/features/unix/thread.prf: +/usr/share/qt4/mkspecs/features/moc.prf: +/usr/share/qt4/mkspecs/features/resources.prf: +/usr/share/qt4/mkspecs/features/uic.prf: +/usr/share/qt4/mkspecs/features/yacc.prf: +/usr/share/qt4/mkspecs/features/lex.prf: +/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/x86_64-linux-gnu/libQtGui.prl: +/usr/lib/x86_64-linux-gnu/libQtCore.prl: +qmake: FORCE + @$(QMAKE) -o Makefile iLPlatform.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/iLPlatform1.0.0 || $(MKDIR) .tmp/iLPlatform1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/iLPlatform1.0.0/ && $(COPY_FILE) --parents test.cpp .tmp/iLPlatform1.0.0/ && (cd `dirname .tmp/iLPlatform1.0.0` && $(TAR) iLPlatform1.0.0.tar iLPlatform1.0.0 && $(COMPRESS) iLPlatform1.0.0.tar) && $(MOVE) `dirname .tmp/iLPlatform1.0.0`/iLPlatform1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/iLPlatform1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: +compiler_moc_header_clean: +compiler_rcc_make_all: +compiler_rcc_clean: +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: + +####### Compile + +test.o: test.cpp iLAbstractPlatform.h \ + iLArchitecture.h \ + iLCompiler.h \ + iLOperatingSystem.h \ + iLPlatform.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o test.o test.cpp + +####### Install + +install: FORCE + +uninstall: FORCE + +FORCE: + diff --git a/invertedlogic/iLPlatform/iLAbstractPlatform.h b/invertedlogic/iLPlatform/iLAbstractPlatform.h new file mode 100644 index 0000000..d7f5753 --- /dev/null +++ b/invertedlogic/iLPlatform/iLAbstractPlatform.h @@ -0,0 +1,20 @@ +#ifndef IL_ABSTRACT_PLATFORM_H +#define IL_ABSTRACT_PLATFORM_H + + +// Detection functions +#include "iLArchitecture.h" +#include "iLCompiler.h" +#include "iLOperatingSystem.h" +#include "iLPlatform.h" + + +// Various platform independent facilities +#include "iLTypes.h" +#include "iLThreads.h" + + + +#endif // IL_ABSTRACT_PLATFORM_H + + diff --git a/invertedlogic/iLPlatform/iLArchitecture.h b/invertedlogic/iLPlatform/iLArchitecture.h new file mode 100644 index 0000000..aa01149 --- /dev/null +++ b/invertedlogic/iLPlatform/iLArchitecture.h @@ -0,0 +1,26 @@ +#ifndef IL_ARCHITECTURE_H +#define IL_ARCHITECTURE_H + + +#if defined(__x86_64__) +# define IL_ARCHITECTURE_X64 1 +# define IL_ARCHITECTURE "x64" +#elif defined(__i386__) +# define IL_ARCHITECTURE_X86 1 +# define IL_ARCHITECTURE "x86" +#elif defined(__ppc__) +# define IL_ARCHITECTURE_PPC 1 +# define IL_ARCHITECTURE "PowerPC" +#elif defined(__arm__) +# define IL_ARCHITECTURE_ARN 1 +# define IL_ARCHITECTURE "ARM" +#elif defined(__mips__) +# define IL_ARCHITECTURE_MIPS 1 +# define IL_ARCHITECTURE "MIPS" +#else +# error "Undetected architecture" +#endif + + +#endif // IL_ARCHITECTURE_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.h b/invertedlogic/iLPlatform/iLAtomics.h new file mode 100644 index 0000000..bab0b7c --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.h @@ -0,0 +1,16 @@ +#ifndef IL_ATOMICS_H +#define IL_ATOMICS_H + + +#include "iLTypes.h" + + +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val); +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val); + + +#include "iLAtomics.inl" + + +#endif // IL_ATOMICS_H + diff --git a/invertedlogic/iLPlatform/iLAtomics.inl b/invertedlogic/iLPlatform/iLAtomics.inl new file mode 100644 index 0000000..37899eb --- /dev/null +++ b/invertedlogic/iLPlatform/iLAtomics.inl @@ -0,0 +1,34 @@ +#include "iLPlatform.h" +#include "iLOperatingSystem.h" + + +// Returns the original value pointed to by a_ptr +// If that value is the same as a_comparand, then *a_ptr is assigned a_val +int32_t iLAtomic_CompareAndSwap32(iLAtomic32* a_ptr, int32_t a_comparand, int32_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int32_t ret = *a_ptr; + OSAtomicCompareAndSwap32(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + +int64_t iLAtomic_CompareAndSwap64(iLAtomic64* a_ptr, int64_t a_comparand, int64_t a_val) +{ +#if defined(IL_PLATFORM_WINDOWS) + return InterlockedCompareExchange64(a_ptr, a_val, a_comparand); +#elif defined(IL_OPERATING_SYSTEM_MACOSX) + int64_t ret = *a_ptr; + OSAtomicCompareAndSwap64(a_comparand, a_val, a_ptr); + return ret; +#elif defined(IL_PLATFORM_UNIX) + return __sync_val_compare_and_swap(a_ptr, a_comparand, a_val); +#endif +} + + diff --git a/invertedlogic/iLPlatform/iLCompiler.h b/invertedlogic/iLPlatform/iLCompiler.h new file mode 100644 index 0000000..4332dbd --- /dev/null +++ b/invertedlogic/iLPlatform/iLCompiler.h @@ -0,0 +1,23 @@ +#ifndef IL_COMPILER_H +#define IL_COMPILER_H + + +#if defined(MSVC) + +# define IL_COMPILER_MSVC 1 +# define IL_COMPILER "MSVC" + +#elif defined(GCC) || defined(__GNUC__) + +# define IL_COMPILER_GCC 1 +# define IL_COMPILER "GCC" + +#else + +# error "Undetected compiler" + +#endif + + +#endif // IL_COMPILER_H + diff --git a/invertedlogic/iLPlatform/iLOperatingSystem.h b/invertedlogic/iLPlatform/iLOperatingSystem.h new file mode 100644 index 0000000..c4dbb70 --- /dev/null +++ b/invertedlogic/iLPlatform/iLOperatingSystem.h @@ -0,0 +1,23 @@ +#ifndef IL_OPERATING_SYSTEM_H +#define IL_OPERATING_SYSTEM_H + + +#if defined(ANDROID) || defined(__ANDROID__) +# define IL_OPERATING_SYSTEM_ANDROID 1 +# define IL_OPERATING_SYSTEM "Android" +#elif defined(linux) || defined(__linux__) +# define IL_OPERATING_SYSTEM_LINUX 1 +# define IL_OPERATING_SYSTEM "Linux" +#elif defined(MACOSX) || (defined(__DARWIN__) && defined(__APPLE__)) +# define IL_OPERATING_SYSTEM_MACOSX 1 +# define IL_OPERATING_SYSTEM "MacOSX" +#elif defined(_WIN32) +# define IL_OPERATING_SYSTEM_WINDOWS 1 +# define IL_OPERATING_SYSTEM "Windows" +#else +# error "Undetected operating system" +#endif + + +#endif // IL_OPERATING_SYSTEM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform b/invertedlogic/iLPlatform/iLPlatform new file mode 100755 index 0000000..2329aa2 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform Binary files differ diff --git a/invertedlogic/iLPlatform/iLPlatform.h b/invertedlogic/iLPlatform/iLPlatform.h new file mode 100644 index 0000000..de4edb6 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.h @@ -0,0 +1,17 @@ +#ifndef IL_PLATFORM_H +#define IL_PLATFORM_H + + +#if defined(_WIN32) +# define IL_PLATFORM_WINDOWS 1 +# define IL_PLATFORM "Windows" +#elif defined(unix) || defined(__unix__) +# define IL_PLATFORM_UNIX 1 +# define IL_PLATFORM "Unix" +#else +# error "Undetected platform" +#endif + + +#endif // IL_PLATFORM_H + diff --git a/invertedlogic/iLPlatform/iLPlatform.pro b/invertedlogic/iLPlatform/iLPlatform.pro new file mode 100644 index 0000000..67da2f7 --- /dev/null +++ b/invertedlogic/iLPlatform/iLPlatform.pro @@ -0,0 +1,6 @@ + +TEMPLATE = app + +SOURCES += test.cpp + + diff --git a/invertedlogic/iLPlatform/iLSemaphore.h b/invertedlogic/iLPlatform/iLSemaphore.h new file mode 100644 index 0000000..42df4e4 --- /dev/null +++ b/invertedlogic/iLPlatform/iLSemaphore.h @@ -0,0 +1,119 @@ +#include +#include /* For O_* constants */ +#include /* For mode constants */ +#include + + +#if 1 + +typedef pthread_mutex_t iLMutex; +typedef sem_t iLSemaphore; + +static inline void iLMutex_Create(iLMutex* a_mutex) +{ + pthread_mutex_init(a_mutex, NULL); +} + +static inline void iLMutex_Lock(iLMutex* a_mutex) +{ + pthread_mutex_lock(a_mutex); +} + +static inline void iLMutex_Unlock(iLMutex* a_mutex) +{ + pthread_mutex_unlock(a_mutex); +} + +static inline void iLSemaphore_Create(iLSemaphore* a_sem, uint32_t a_initCount, uint32_t a_maxCount) +{ + a_sem = sem_open("/sem", O_CREAT, S_IRWXU, a_initCount); +} + +static inline void iLSemaphore_Wait(iLSemaphore* a_sem) +{ + sem_wait(a_sem); +} + +static inline void iLSemaphore_Signal(iLSemaphore* a_sem, uint32_t a_count) +{ + for (int i = 0; i < a_count; i++) + sem_post(a_sem); +} + +#else + +typedef uint32_t iLMutex; + +static inline void iLMutex_Create(iLMutex* a_mutex) +{ + *a_mutex = 0; +} + +static inline void iLMutex_Lock(iLMutex* a_mutex) +{ + int spinCount = 0; + while (__sync_lock_test_and_set(a_mutex, 1) == 1) + { + spinCount++; + if (spinCount > 1000000) + { + spinCount = 0; + pthread_yield(); + } + } +} + +static inline void iLMutex_Unlock(iLMutex* a_mutex) +{ + __sync_lock_release(a_mutex); +} + +struct iLSemaphore +{ + uint32_t count; + uint32_t maxCount; + uint32_t waitCount; + iLMutex mutex; + pthread_cond_t cond; +}; + +static inline void iLSemaphore_Create(iLSemaphore* a_sem, uint32_t a_initCount, iLMutex* a_maxCount) +{ + a_sem->count = a_initCount; + a_sem->maxCount = a_maxCount; + a_sem->waitCount = 0; + iLMutex_Create(&a_sem->mutex); + pthread_cond_init(&a_sem->cond, NULL); +} + +static inline void iLSemaphore_Wait(iLSemaphore* a_sem) +{ + iLMutex_Lock(&a_sem->mutex); + while(a_sem->count == 0) + { + ++a_sem->waitCount; + pthread_cond_wait(&a_sem->cond, &a_sem->mutex); + --a_sem->waitCount; + } + --a_sem->count; + iLMutex_Unlock(&a_sem->mutex); +} + +static inline void iLSemaphore_Signal(iLSemaphore* a_sem, uint32_t a_count) +{ + iLMutex_Lock(&a_sem->mutex); + a_sem->count += a_count; + if (a_sem->count > a_sem->maxCount) + { + a_sem->count = a_sem->maxCount; + } + if (a_sem->waitCount > 0) + { + pthread_cond_signal(&a_sem->cond); + } + iLMutex_Unlock(&a_sem->mutex); +} + +#endif + + diff --git a/invertedlogic/iLPlatform/iLThreads.h b/invertedlogic/iLPlatform/iLThreads.h new file mode 100644 index 0000000..6d1b20d --- /dev/null +++ b/invertedlogic/iLPlatform/iLThreads.h @@ -0,0 +1,21 @@ +#ifndef IL_THREAD_H +#define IL_THREAD_H + + +#include "iLTypes.h" + + +typedef iLResult (*iLThreadProc)(void); + + +static inline iLResult iLThread_Create(iLThread* a_thread, iLThreadProc a_proc); +static inline iLResult iLThread_Destroy(iLThread* a_thread); +static inline iLResult iLThread_GetCurrent(iLThread* a_thread); +static inline iLResult iLThread_Yield(); + + +#include "iLThreads.inl" + + +#endif // IL_THREAD_H + diff --git a/invertedlogic/iLPlatform/iLThreads.inl b/invertedlogic/iLPlatform/iLThreads.inl new file mode 100644 index 0000000..ef633f0 --- /dev/null +++ b/invertedlogic/iLPlatform/iLThreads.inl @@ -0,0 +1,50 @@ + + +#if defined(IL_PLATFORM_UNIX) + + +static inline void *internalThreadStartProc(void *a_arg) +{ + return (void*)((iLThreadProc)a_arg)(); +} + + +static inline iLResult iLThread_Create(iLThread* a_thread, iLThreadProc a_proc) +{ + return ((pthread_create(a_thread, NULL, internalThreadStartProc, (void*)a_proc) == 0) ? iLR_OK : iLR_UnspecifiedFailure); +} + + +static inline iLResult iLThread_Destroy(iLThread* a_thread) +{ + if (a_thread == 0 || pthread_cancel(*a_thread) != 0) + return iLR_UnspecifiedFailure; + return (pthread_join(*a_thread, NULL) == 0) ? iLR_OK : iLR_UnspecifiedFailure; +} + + +static inline iLResult iLThread_GetCurrent(iLThread* a_thread) +{ + if (!a_thread) + return iLR_UnspecifiedFailure; + *a_thread = pthread_self(); + return iLR_OK; +} + + +static inline iLResult iLThread_Yield() +{ + pthread_yield(); + return iLR_OK; +} + + +#else + +// XXX TODO add windoes specific thread ode +# error "platform code not implemented" + +#endif + + + diff --git a/invertedlogic/iLPlatform/iLTypes.h b/invertedlogic/iLPlatform/iLTypes.h new file mode 100644 index 0000000..a525182 --- /dev/null +++ b/invertedlogic/iLPlatform/iLTypes.h @@ -0,0 +1,35 @@ +#ifndef IL_TYPES_H +#define IL_TYPES_H + + +#include +#include "iLPlatform.h" + + +#if defined(IL_PLATFORM_UNIX) +#include +typedef pthread_t iLThread; +typedef int32_t* iLAtomic32; +typedef int64_t* iLAtomic64; +#elif defined(IL_PLATFORM_WINDOWS) +#include +typedef HANDLE iLThread; +typedef volatile int32_t* iLAtomic32; +typedef volatile int64_t* iLAtomic64; +#else +# error "Unsupported platform" +#endif + + +enum iLResult +{ + iLR_OK, + iLR_UnspecifiedFailure +}; + + +typedef iLResult (*iLThreadProc)(void); + + +#endif // IL_TYPES_H + diff --git a/invertedlogic/iLPlatform/test.cpp b/invertedlogic/iLPlatform/test.cpp new file mode 100644 index 0000000..810ec1f --- /dev/null +++ b/invertedlogic/iLPlatform/test.cpp @@ -0,0 +1,52 @@ +#include +#include "iLAbstractPlatform.h" +#include "iLThreads.h" +#include "iLSemaphore.h" +#include + + +iLSemaphore g_sem; + + +iLResult run1(void) +{ + sleep(1); + printf(" running1 \n"); + iLSemaphore_Signal(&g_sem, 1); + return iLR_OK; +} + + +iLResult run2(void) +{ + sleep(3); + printf(" running2 \n"); + iLSemaphore_Signal(&g_sem, 1); + return iLR_OK; +} + + +int main() +{ + iLSemaphore_Create(&g_sem, 0, 100); + + iLThread thread1, thread2; + iLThread_Create(&thread1, run1); + iLThread_Create(&thread2, run2); + + printf("Detected the following:\n"); + printf(" Architecture: " IL_ARCHITECTURE "\n"); + printf(" Compiler: " IL_COMPILER "\n"); + printf(" Operating System: " IL_OPERATING_SYSTEM "\n"); + printf(" Platform: " IL_PLATFORM "\n"); + + iLSemaphore_Wait(&g_sem); + iLSemaphore_Wait(&g_sem); + + iLThread_Destroy(&thread1); + iLThread_Destroy(&thread2); + + return 1; +} + +