You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
3.5 KiB
125 lines
3.5 KiB
/***************************************************************************
|
|
* system.h
|
|
*
|
|
* Copyright 2009 - Steffen Pohle
|
|
* steffen@gulpe.de
|
|
****************************************************************************/
|
|
|
|
/*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#ifndef _SYSTEM_H_
|
|
#define _SYSTEM_H_
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__)
|
|
#define POINTERALIGNMENT 4
|
|
#include <sys/wait.h>
|
|
#include <errno.h>
|
|
#if !defined(ANDROID)
|
|
#include <execinfo.h>
|
|
#endif
|
|
#else
|
|
#if defined(__MINGW32CE__) || defined(_WIN32_WCE)
|
|
#define POINTERALIGNMENT 8
|
|
#define errno 0
|
|
#define strerror(_t) "no strerror support in winCE"
|
|
#else
|
|
#define POINTERALIGNMENT 4
|
|
#endif
|
|
#endif
|
|
#include <math.h>
|
|
#include <limits.h>
|
|
#include <float.h>
|
|
#include <stdarg.h>
|
|
|
|
#if defined(__MINGW32CE__) || defined(_WIN32_WCE)
|
|
#define DIR_SEP '/'
|
|
#define ROOT_DIR "/"
|
|
#else
|
|
#if defined(__MINGW32__)
|
|
#define DIR_SEP '\\'
|
|
#define ROOT_DIR "C:\\"
|
|
#else
|
|
#define DIR_SEP '/'
|
|
#define ROOT_DIR "/"
|
|
#endif
|
|
#endif
|
|
|
|
#define SETFLAG(__flag, __opt) (__flag |= __opt)
|
|
#define DELFLAG(__flag, __opt) (__flag &= (0x0FFFF - __opt))
|
|
#define ISFLAG(__flag, __opt) (__flag & __opt)
|
|
#define ISNOTFLAG(__flag, __opt) (!(__flag & __opt))
|
|
|
|
struct s_execcall {
|
|
int used;
|
|
pid_t pid;
|
|
};
|
|
|
|
extern int cmpf (float f1, float f2);
|
|
extern int cmpd (double d1, double d2);
|
|
|
|
|
|
#ifdef ANDROID
|
|
#include <jni.h>
|
|
#include <errno.h>
|
|
#include <EGL/egl.h>
|
|
#include <GLES/gl.h>
|
|
#include <android/sensor.h>
|
|
#include <android/log.h>
|
|
#include <android_native_app_glue.h>
|
|
|
|
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__))
|
|
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "sposmroute", __VA_ARGS__))
|
|
// #define d_printf(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sposmroute", __VA_ARGS__))
|
|
extern void d_printf (char *fmt,...);
|
|
#else
|
|
|
|
extern void d_printf (char *fmt,...);
|
|
#endif
|
|
extern void d_print_init();
|
|
extern void d_print_backtrace ();
|
|
extern void d_print_stat ();
|
|
extern void d_print_data (char *data, int len);
|
|
|
|
extern void errorexit (int nr);
|
|
extern int execcall (struct s_execcall *p, char *prg, char **argv);
|
|
extern int execwait (struct s_execcall *p);
|
|
|
|
extern unsigned long long int getticks ();
|
|
extern char **get_backtrace (int *cnt);
|
|
|
|
extern char *mempush (void *mem, void *source, int size);
|
|
extern char *mempop (void *mem, void *dest, int size);
|
|
extern char *memstrpop (void *mem, void *dest, int *size);
|
|
|
|
#if !defined(ANDROID)
|
|
extern void memswap (void *mem1, void *mem2, int size); // maximum 32 bytes
|
|
#endif
|
|
|
|
int file_exist (char *fn);
|
|
int dir_exist (char *fn);
|
|
|
|
extern char* flags2text (int f, char *text);
|
|
|
|
#endif
|