Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request libhybris#7 from morphis/morphis/common-rework
Morphis/common rework
  • Loading branch information
stskeeps committed Apr 4, 2013
2 parents b94bc94 + 032cd9e commit a0d2be2
Show file tree
Hide file tree
Showing 20 changed files with 174 additions and 37 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Expand Up @@ -24,3 +24,13 @@ ltmain.sh
ylwrap
compile
stamp-h1

aclocal-copy
arm-*-linux-gnueabi-libtool

tests/test_egl
tests/test_glesv2
tests/test_lights
tests/test_offscreen_rendering
tests/test_sensors
tests/test_ui
4 changes: 2 additions & 2 deletions configure.ac
Expand Up @@ -85,9 +85,9 @@ AC_ARG_ENABLE(alinker,
exit -1
fi
],
[alinker="gingerbread"]
[alinker="gb"]
)
AM_CONDITIONAL([WANT_GB], [test x$alinker = xbg])
AM_CONDITIONAL([WANT_GB], [test x$alinker = xgb])
AM_CONDITIONAL([WANT_ICS], [test x$alinker = xics])
AM_CONDITIONAL([WANT_JB], [test x$alinker = xjb])

Expand Down
2 changes: 1 addition & 1 deletion egl/fbdev_window.h
Expand Up @@ -2,7 +2,7 @@
#define FBDEV_WINDOW_H
#include "nativewindowbase.h"
#include <linux/fb.h>
#include <hardware/gralloc.h>
#include <android/hardware/gralloc.h>
#define FRAMEBUFFER_PARTITIONS 2

class FbDevNativeWindowBuffer : public BaseNativeWindowBuffer
Expand Down
2 changes: 1 addition & 1 deletion egl/native_handle.c
Expand Up @@ -22,7 +22,7 @@
#include <stdlib.h>
#include <unistd.h>

#include <cutils/native_handle.h>
#include <android/cutils/native_handle.h>

native_handle_t* native_handle_create(int numFds, int numInts)
{
Expand Down
4 changes: 2 additions & 2 deletions egl/nativewindowbase.cpp
@@ -1,5 +1,5 @@
#include <system/window.h>
#include <hardware/gralloc.h>
#include <android/system/window.h>
#include <android/hardware/gralloc.h>
#include "support.h"
#include <stdarg.h>

Expand Down
2 changes: 1 addition & 1 deletion egl/nativewindowbase.h
@@ -1,7 +1,7 @@
#ifndef NATIVEWINDOWBASE_H
#define NATIVEWINDOWBASE_H

#include <system/window.h>
#include <android/system/window.h>
#include <EGL/egl.h>

#define NO_ERROR 0L
Expand Down
2 changes: 1 addition & 1 deletion egl/offscreen_window.cpp
Expand Up @@ -22,7 +22,7 @@
#include <sys/mman.h> //mmap, munmap
#include <errno.h>

#include <hardware/gralloc.h>
#include <android/hardware/gralloc.h>

#include "nativewindowbase.h"
#include "offscreen_window.h"
Expand Down
2 changes: 1 addition & 1 deletion egl/offscreen_window.h
Expand Up @@ -2,7 +2,7 @@
#define OFFSCREEN_WINDOW_H

#include <linux/fb.h>
#include <hardware/gralloc.h>
#include <android/hardware/gralloc.h>

#include "nativewindowbase.h"

Expand Down
22 changes: 11 additions & 11 deletions include/Makefile.am
Expand Up @@ -39,19 +39,19 @@ vginclude_HEADERS = \
VG/vgplatform.h \
VG/vgu.h

cutilsincludedir = $(includedir)/cutils
cutilsincludedir = $(includedir)/android/cutils
cutilsinclude_HEADERS = \
cutils/native_handle.h
android/cutils/native_handle.h

systemincludedir = $(includedir)/system
systemincludedir = $(includedir)/android/system
systeminclude_HEADERS = \
system/window.h \
system/graphics.h
android/system/window.h \
android/system/graphics.h

hardwareincludedir = $(includedir)/hardware
hardwareincludedir = $(includedir)/android/hardware
hardwareinclude_HEADERS = \
hardware/fb.h \
hardware/gralloc.h \
hardware/hardware.h \
hardware/sensors.h \
hardware/lights.h
android/hardware/fb.h \
android/hardware/gralloc.h \
android/hardware/hardware.h \
android/hardware/sensors.h \
android/hardware/lights.h
File renamed without changes.
5 changes: 2 additions & 3 deletions include/hardware/fb.h → include/android/hardware/fb.h
Expand Up @@ -22,9 +22,8 @@
#include <sys/cdefs.h>
#include <sys/types.h>

#include <cutils/native_handle.h>

#include <hardware/hardware.h>
#include <android/cutils/native_handle.h>
#include <android/hardware/hardware.h>

__BEGIN_DECLS

Expand Down
Expand Up @@ -18,17 +18,17 @@
#ifndef ANDROID_GRALLOC_INTERFACE_H
#define ANDROID_GRALLOC_INTERFACE_H

#include <system/window.h>
#include <hardware/hardware.h>
#include <android/system/window.h>
#include <android/hardware/hardware.h>

#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>

#include <cutils/native_handle.h>
#include <android/cutils/native_handle.h>

#include <hardware/hardware.h>
#include <hardware/fb.h>
#include <android/hardware/hardware.h>
#include <android/hardware/fb.h>

__BEGIN_DECLS

Expand Down
Expand Up @@ -20,8 +20,8 @@
#include <stdint.h>
#include <sys/cdefs.h>

#include <cutils/native_handle.h>
#include <system/graphics.h>
#include <android/cutils/native_handle.h>
#include <android/system/graphics.h>

__BEGIN_DECLS

Expand Down
Expand Up @@ -21,7 +21,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>

#include <hardware/hardware.h>
#include <android/hardware/hardware.h>

__BEGIN_DECLS

Expand Down
Expand Up @@ -21,8 +21,8 @@
#include <sys/cdefs.h>
#include <sys/types.h>

#include <hardware/hardware.h>
#include <cutils/native_handle.h>
#include <android/hardware/hardware.h>
#include <android/cutils/native_handle.h>

__BEGIN_DECLS

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions include/system/window.h → include/android/system/window.h
Expand Up @@ -22,8 +22,8 @@
#include <string.h>
#include <sys/cdefs.h>

#include <system/graphics.h>
#include <cutils/native_handle.h>
#include <android/system/graphics.h>
#include <android/cutils/native_handle.h>

__BEGIN_DECLS

Expand Down
128 changes: 128 additions & 0 deletions include/hybris/internal/binding.h
@@ -0,0 +1,128 @@
/*
* Copyright (C) 2013 Simon Busch <morphis@gravedo.de>
* 2012 Canonical Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef HYBRIS_BINDING_H_
#define HYBRIS_BINDING_H_

void *android_dlopen(const char *filename, int flag);
void *android_dlsym(void *name, const char *symbol);

#define HYBRIS_DLSYSM(name, fptr, sym) \
if (!name##_handle) \
hybris_##name##_initialize(); \
if (*(fptr) == NULL) \
{ \
*(fptr) = (void *) android_dlsym(name##_handle, sym); \
}

#define HYBRIS_LIBRARY_INITIALIZE(name, path) \
void *name##_handle; \
void hybris_##name##_initialize() \
{ \
name##_handle = android_dlopen(path, RTLD_LAZY); \
}

#define HYBRIS_IMPLEMENT_FUNCTION0(name, return_type, symbol) \
return_type symbol() \
{ \
static return_type (*f)() = NULL; \
HYBRIS_DLSYSM(name, &f, #symbol); \
return f(); \
}

#define HYBRIS_IMPLEMENT_FUNCTION1(name, return_type, symbol, arg1) \
return_type symbol(arg1 _1) \
{ \
static return_type (*f)(arg1) = NULL; \
HYBRIS_DLSYSM(name, &f, #symbol); \
return f(_1); \
}

#define HYBRIS_IMPLEMENT_FUNCTION2(name, return_type, symbol, arg1, arg2) \
return_type symbol(arg1 _1, arg2 _2) \
{ \
static return_type (*f)(arg1, arg2) = NULL; \
HYBRIS_DLSYSM(name, &f, #symbol); \
return f(_1, _2); \
}

#define HYBRIS_IMPLEMENT_FUNCTION3(name, return_type, symbol, arg1, arg2, arg3) \
return_type symbol(arg1 _1, arg2 _2, arg3 _3) \
{ \
static return_type (*f)(arg1, arg2, arg3) = NULL; \
HYBRIS_DLSYSM(name, &f, #symbol); \
return f(_1, _2, _3); \
}

#define HYBRIS_IMPLEMENT_FUNCTION4(name, return_type, symbol, arg1, arg2, arg3, arg4) \
return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \
{ \
static return_type (*f)(arg1, arg2, arg3, arg4) = NULL; \
HYBRIS_DLSYSM(name, &f, #symbol); \
return f(_1, _2, _3, _4); \
}

#define HYBRIS_IMPLEMENT_FUNCTION5(name, return_type, symbol, arg1, arg2, arg3, arg4, arg5) \
return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5) \
{ \
static return_type (*f)(arg1, arg2, arg3, arg4, arg5) = NULL; \
HYBRIS_DLSYSM(name, &f, #symbol); \
return f(_1, _2, _3, _4, _5); \
}

#define HYBRIS_IMPLEMENT_FUNCTION6(name, return_type, symbol, arg1, arg2, arg3, arg4, arg5, arg6) \
return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6) \
{ \
static return_type (*f)(arg1, arg2, arg3, arg4, arg5, arg6) = NULL; \
HYBRIS_DLSYSM(name, &f, #symbol); \
return f(_1, _2, _3, _4, _5, _6); \
}

#define HYBRIS_IMPLEMENT_FUNCTION7(name, return_type, symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6, arg7 _7) \
{ \
static return_type (*f)(arg1, arg2, arg3, arg4, arg5, arg6, arg7) = NULL; \
HYBRIS_DLSYSM(name, &f, #symbol); \
return f(_1, _2, _3, _4, _5, _6, _7); \
}

#define HYBRIS_IMPLEMENT_VOID_FUNCTION1(name, symbol, arg1) \
void symbol(arg1 _1) \
{ \
static void (*f)(arg1) = NULL; \
HYBRIS_DLSYSM(name, &f, #symbol); \
f(_1); \
}

#define HYBRIS_IMPLEMENT_VOID_FUNCTION2(name, symbol, arg1, arg2) \
void symbol(arg1 _1, arg2 _2) \
{ \
static void (*f)(arg1, arg2) = NULL; \
HYBRIS_DLSYSM(name, &f, #symbol); \
f(_1, _2); \
}

#define HYBRIS_IMPLEMENT_VOID_FUNCTION3(name, symbol, arg1, arg2, arg3) \
void symbol(arg1 _1, arg2 _2, arg3 _3) \
{ \
static void (*f)(arg1, arg2, arg3) = NULL; \
HYBRIS_DLSYSM(name, &f, #symbol); \
f(_1, _2, _3); \
}


#endif
2 changes: 1 addition & 1 deletion tests/test_lights.c
Expand Up @@ -18,7 +18,7 @@
#include <memory.h>
#include <assert.h>
#include <stdio.h>
#include <hardware/lights.h>
#include <android/hardware/lights.h>

int main(int argc, char **argv)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sensors.c
Expand Up @@ -17,7 +17,7 @@

#include <assert.h>
#include <stdio.h>
#include <hardware/sensors.h>
#include <android/hardware/sensors.h>

int main(int argc, char **argv)
{
Expand Down

0 comments on commit a0d2be2

Please sign in to comment.