Эх сурвалжийг харах

Abhängigkeiten testweise bereinigt
Makefile dazugemacht für Buildroot
Release und Debugverzeichnis wird beim Make erzeugt (für Buildroot)

Abhängigkeiten:
geändert: src/timer.h

Dateien aus libgfaipc kopiert:

src/Makefile
src/mutex.h
src/uuid.h

@Iwan: warum ist das so, oder ist das OK

Reinhard Russinger 7 жил өмнө
parent
commit
8411820ea5
4 өөрчлөгдсөн 174 нэмэгдсэн , 1 устгасан
  1. 58 0
      src/Makefile
  2. 66 0
      src/mutex.h
  3. 1 1
      src/timer.h
  4. 49 0
      src/uuid.h

+ 58 - 0
src/Makefile

@@ -0,0 +1,58 @@
+# (c) R. Russinger GfA 2017,... LGPL v3
+#
+# Makefile for GfA Libraries
+# call with make DEBUG=1 for Debug output
+# output is held in Release or Debug subfolder (folders are created automaticalle)
+# make Variable for foldernames := BINDIR
+#
+#
+DEBUG ?= 0
+        
+_LIBBASENAME=gfatimer
+LIBFILENAME=lib$(LIBBASENAME).so.1.0.0
+
+CFLAGS = -c -pthread -fPIC -Wall -Wno-unused -Wno-unused-label -Wformat -Wuninitialized -Wundef -Wcast-qual -Wwrite-strings -fabi-version=2 -fno-omit-frame-pointer
+CXXFLAGS = -c -pthread -fPIC -Wall -Wno-unused -Wno-unused-label -Wformat -Wuninitialized -Wundef -Wcast-qual -Wwrite-strings -std=c++11 -fabi-version=2 -fno-omit-frame-pointer
+LDFLAGS = -fPIC -shared -L. -lc -pthread
+
+ifeq ($(DEBUG), 1)
+	CFLAGS += -g
+	CXXFLAGS += -g
+	LDFLAGS += -g
+	LIBBASENAME = $(_LIBBASENAME)d
+	BINDIR=Debug
+else
+	CFLAGS += -O3
+	CXXFLAGS += -O3
+	LDFLAGS += -O3
+	LIBBASENAME = $(_LIBBASENAME)
+	BINDIR=Release
+endif
+
+$(shell mkdir -p $(BINDIR) > /dev/null)
+
+TARGET_LIB = $(LIBFILENAME) # target lib
+
+CSRCS =   # source files
+CXXSRCS = timer.cpp gfatimer.cpp # source files
+
+COBJS = $(CSRCS:%.c=$(BINDIR)/%.o)
+CXXOBJS = $(CXXSRCS:%.cpp=$(BINDIR)/%.o)
+
+.PHONY: all
+all: $(BINDIR)/${TARGET_LIB}
+
+$(BINDIR)/$(TARGET_LIB): $(COBJS) $(CXXOBJS)
+	$(CC) ${LDFLAGS} -o $@ $^
+	
+$(CSRCS:%.c=$(BINDIR)/%.d):$(BINDIR)/%.d:%.c
+	$(CC) $(CFLAGS) -MP -MT $(basename $@).o -MMD -MF $@ -o $(basename $@).o $<
+
+$(CXXSRCS:%.cpp=$(BINDIR)/%.dpp):$(BINDIR)/%.dpp:%.cpp
+	$(CXX) $(CXXFLAGS) -MP -MT $(basename $@).o -MMD -MF $@ -o $(basename $@).o $<
+
+include $(CSRCS:%.c=$(BINDIR)/%.d) $(CXXSRCS:%.cpp=$(BINDIR)/%.dpp)
+
+.PHONY: clean
+clean:
+	@rm -rf $(BINDIR)

+ 66 - 0
src/mutex.h

@@ -0,0 +1,66 @@
+// mutex.h :
+//
+
+#if !defined(AGD_MUTEX_H__307A751D_EF2D_45D6_BBA8_2EB4B79B548D__INCLUDED_)
+#define AGD_MUTEX_H__307A751D_EF2D_45D6_BBA8_2EB4B79B548D__INCLUDED_
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include "uuid.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// mutex.h - Declarations:
+
+#ifdef _WIN32
+#define _DEF_MUTEX_DIR						"."
+#endif	//	_WIN32
+
+#ifdef __linux__
+#define _DEF_MUTEX_DIR						"/tmp"
+#endif	//	__linux__
+
+/////////////////////////////////////////////////////////////////////////////
+
+class CGlobalMutex
+{
+public:
+	CGlobalMutex(void);
+	virtual ~CGlobalMutex(void);
+
+	int Create(const uuid_t &ruuid, const char *pszDir = _DEF_MUTEX_DIR);
+	long Release(void);
+
+	bool Lock(void);
+	bool TryLock(void);
+	bool Unlock(void);
+
+private:
+	int m_nShmID;
+	pthread_mutexattr_t m_mutexAttr;
+	pthread_mutex_t *m_pMutex;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+class CLocalMutex
+{
+public:
+	CLocalMutex(void);
+	virtual ~CLocalMutex(void);
+
+	bool Create(bool bRecursive = false);
+	void Release(void);
+
+	bool Lock(void);
+	bool TryLock(void);
+	bool Unlock(void);
+
+private:
+	bool m_bInit;
+	pthread_mutexattr_t m_mutexAttr;
+	pthread_mutex_t m_mutex;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+#endif	//	!defined(AGD_MUTEX_H__307A751D_EF2D_45D6_BBA8_2EB4B79B548D__INCLUDED_)

+ 1 - 1
src/timer.h

@@ -6,7 +6,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "../../gfaipc/src/mutex.h"
+#include "mutex.h"
 #include "gfatimer.h"
 
 /////////////////////////////////////////////////////////////////////////////

+ 49 - 0
src/uuid.h

@@ -0,0 +1,49 @@
+// uuid.h :
+//
+
+#if !defined(AGD_UUID_H__E2CBFDC3_1EA5_4220_8D44_D0C26219B529__INCLUDED_)
+#define AGD_UUID_H__E2CBFDC3_1EA5_4220_8D44_D0C26219B529__INCLUDED_
+
+#include <inttypes.h>
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif	//	__cplusplus
+
+/////////////////////////////////////////////////////////////////////////////
+// uuid.h - Declarations:
+
+#ifdef __linux__
+typedef struct _UUID
+{
+    uint32_t Data1;
+    uint16_t Data2;
+    uint16_t Data3;
+    uint8_t  Data4[8];
+}UUID;
+#define uuid_t UUID
+#endif	//	__linux__
+
+#define DEFINE_UUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+											const uuid_t name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
+
+#define _UUID_STRING_LEN					36
+
+/////////////////////////////////////////////////////////////////////////////
+
+extern const uuid_t UUID_NULL;
+
+/////////////////////////////////////////////////////////////////////////////
+
+int		_uuid_parse		(const char *pszIn, uuid_t *uuid);
+int		_uuid_unparse	(const uuid_t *uuid, char *pszOut, size_t nCChOut);
+int		_uuid_compare	(const uuid_t *uuid1, const uuid_t *uuid2);
+void	_uuid_copy		(uuid_t *uuDest, const uuid_t *uuSrc);
+int		_uuid_is_null	(const uuid_t *uuid);
+
+/////////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+}
+#endif	//	__cplusplus
+#endif	//	!defined(AGD_UUID_H__E2CBFDC3_1EA5_4220_8D44_D0C26219B529__INCLUDED_)