From d386afcc41e92c96778d9b1a498199f48fa2d4aa Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Fri, 15 May 2009 02:11:12 +0200 Subject: revert to previous implementation of __aeabi_atexit() since the new one seems to crash a static ICU String destructor. I don't have the time to investigate why right now, so a revert is preferred. Damn... --- libc/bionic/eabi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libc') diff --git a/libc/bionic/eabi.c b/libc/bionic/eabi.c index 21d8537..2e0c99c 100644 --- a/libc/bionic/eabi.c +++ b/libc/bionic/eabi.c @@ -37,7 +37,8 @@ void* __dso_handle = 0; int __attribute__((weak)) __aeabi_atexit (void *object, void (*destructor) (void *), void *dso_handle) { - return __cxa_atexit(destructor, object, dso_handle); + return 0; + //return __cxa_atexit(destructor, object, dso_handle); } -- cgit v1.1 From 0ba91ed3ca9e7340a2c55303034c3378967e2327 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Wed, 20 May 2009 11:42:52 +0200 Subject: Fix __eabi_atexit() implementation, as well as a bug in the BSD-originated __cxa_finalize() implementation This patch uses "#if ANDROID" instead of "#if 1" in the __cxa_finalize() fix --- libc/bionic/eabi.c | 11 +++++++++-- libc/stdlib/atexit.c | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'libc') diff --git a/libc/bionic/eabi.c b/libc/bionic/eabi.c index 2e0c99c..a5f6627 100644 --- a/libc/bionic/eabi.c +++ b/libc/bionic/eabi.c @@ -32,13 +32,20 @@ extern int __cxa_atexit(void (*)(void*), void*, void* ); void* __dso_handle = 0; +/* The "C++ ABI for ARM" document states that static C++ constructors, + * which are called from the .init_array, should manually call + * __aeabi_atexit() to register static destructors explicitely. + * + * Note that 'dso_handle' is the address of a magic linker-generate + * variable from the shared object that contains the constructor/destructor + */ + /* Make this a weak symbol to avoid a multiple definition error when linking * with libstdc++-v3. */ int __attribute__((weak)) __aeabi_atexit (void *object, void (*destructor) (void *), void *dso_handle) { - return 0; - //return __cxa_atexit(destructor, object, dso_handle); + return __cxa_atexit(destructor, object, dso_handle); } diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c index 5bf82ba..4ba2177 100644 --- a/libc/stdlib/atexit.c +++ b/libc/stdlib/atexit.c @@ -147,10 +147,19 @@ __cxa_finalize(void *dso) p->fns[n].fn_ptr.cxa_func = NULL; mprotect(p, pgsize, PROT_READ); } +#if ANDROID + /* it looks like we should always call the function + * with an argument, even if dso is not NULL. Otherwise + * static destructors will not be called properly on + * the ARM. + */ + (*fn.fn_ptr.cxa_func)(fn.fn_arg); +#else /* !ANDROID */ if (dso != NULL) (*fn.fn_ptr.cxa_func)(fn.fn_arg); else (*fn.fn_ptr.std_func)(); +#endif /* !ANDROID */ } } -- cgit v1.1 From e5446feb21a991426fb683d077a1a8ca5831ac0f Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Wed, 20 May 2009 13:00:10 +0200 Subject: Add and for VPN support. Also update tools/update_all.py to not use perforce add/edit/delete commands automatically now that we're using git --- libc/kernel/common/linux/if_pppolac.h | 29 ++++++++++++++++++ libc/kernel/common/linux/ipsec.h | 56 +++++++++++++++++++++++++++++++++++ libc/kernel/common/linux/msm_audio.h | 1 - libc/kernel/tools/update_all.py | 4 ++- 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 libc/kernel/common/linux/if_pppolac.h create mode 100644 libc/kernel/common/linux/ipsec.h (limited to 'libc') diff --git a/libc/kernel/common/linux/if_pppolac.h b/libc/kernel/common/linux/if_pppolac.h new file mode 100644 index 0000000..bf6eba0 --- /dev/null +++ b/libc/kernel/common/linux/if_pppolac.h @@ -0,0 +1,29 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + **************************************************************************** + ****************************************************************************/ +#ifndef __LINUX_IF_PPPOLAC_H +#define __LINUX_IF_PPPOLAC_H + +#include +#include + +#define PX_PROTO_OLAC 2 + +struct sockaddr_pppolac { + sa_family_t sa_family; + unsigned int sa_protocol; + int udp_socket; + struct __attribute__((packed)) { + __u16 tunnel, session; + } local, remote; +} __attribute__((packed)); + +#endif diff --git a/libc/kernel/common/linux/ipsec.h b/libc/kernel/common/linux/ipsec.h new file mode 100644 index 0000000..56acafa --- /dev/null +++ b/libc/kernel/common/linux/ipsec.h @@ -0,0 +1,56 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + **************************************************************************** + ****************************************************************************/ +#ifndef _LINUX_IPSEC_H +#define _LINUX_IPSEC_H + +#include + +#define IPSEC_PORT_ANY 0 +#define IPSEC_ULPROTO_ANY 255 +#define IPSEC_PROTO_ANY 255 + +enum { + IPSEC_MODE_ANY = 0, + IPSEC_MODE_TRANSPORT = 1, + IPSEC_MODE_TUNNEL = 2, + IPSEC_MODE_BEET = 3 +}; + +enum { + IPSEC_DIR_ANY = 0, + IPSEC_DIR_INBOUND = 1, + IPSEC_DIR_OUTBOUND = 2, + IPSEC_DIR_FWD = 3, + IPSEC_DIR_MAX = 4, + IPSEC_DIR_INVALID = 5 +}; + +enum { + IPSEC_POLICY_DISCARD = 0, + IPSEC_POLICY_NONE = 1, + IPSEC_POLICY_IPSEC = 2, + IPSEC_POLICY_ENTRUST = 3, + IPSEC_POLICY_BYPASS = 4 +}; + +enum { + IPSEC_LEVEL_DEFAULT = 0, + IPSEC_LEVEL_USE = 1, + IPSEC_LEVEL_REQUIRE = 2, + IPSEC_LEVEL_UNIQUE = 3 +}; + +#define IPSEC_MANUAL_REQID_MAX 0x3fff + +#define IPSEC_REPLAYWSIZE 32 + +#endif diff --git a/libc/kernel/common/linux/msm_audio.h b/libc/kernel/common/linux/msm_audio.h index 9ac58aa..eed5901 100644 --- a/libc/kernel/common/linux/msm_audio.h +++ b/libc/kernel/common/linux/msm_audio.h @@ -82,4 +82,3 @@ struct msm_snd_endpoint { #define SND_GET_ENDPOINT _IOWR(SND_IOCTL_MAGIC, 5, struct msm_snd_endpoint *) #endif - diff --git a/libc/kernel/tools/update_all.py b/libc/kernel/tools/update_all.py index 6272fcf..d25dc0e 100755 --- a/libc/kernel/tools/update_all.py +++ b/libc/kernel/tools/update_all.py @@ -73,7 +73,9 @@ for path in sources: print "cleaning: %-*s -> %-*s (%s)" % ( 35, path, 35, dst_path, r ) -usePerforce = os.environ.has_key("ANDROID_PRODUCT_OUT") +# We don't use Perforce anymore, but just in case, define ANDROID_USE_P4 +# in your environment if you think you need it. +usePerforce = os.environ.has_key("ANDROID_USE_P4") if usePerforce: b.updateP4Files() -- cgit v1.1 From 2735b33519595da5d51b79757ccce730021a9228 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Tue, 26 May 2009 23:54:37 +0200 Subject: Fix getservent() so that it returns s_port in network byte order. Also add a new document detailing known issues in the C library. --- libc/docs/ISSUES.TXT | 20 ++++++++++++++++++++ libc/netbsd/net/getservent.c | 9 +++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 libc/docs/ISSUES.TXT (limited to 'libc') diff --git a/libc/docs/ISSUES.TXT b/libc/docs/ISSUES.TXT new file mode 100644 index 0000000..b53eb16 --- /dev/null +++ b/libc/docs/ISSUES.TXT @@ -0,0 +1,20 @@ +Bionic C Library Issues: +======================== + +This document lists important known issues of various releases +of the Bionic C library. Note that these differ from specific +implementation choices that are documented in the OVERVIEW.TXT +document. + +Currently known issues: +----------------------- + +- The C library initialization will improperly run static C++ + constructors located in shared libraries twice. + +Android-1.5 issues: +------------------- + +- getservbyname() returned the port number in the s_port field of + the 'struct servent' structure in host-byte-order, instead of + network-byte-order. diff --git a/libc/netbsd/net/getservent.c b/libc/netbsd/net/getservent.c index 45207df..65fbd7e 100644 --- a/libc/netbsd/net/getservent.c +++ b/libc/netbsd/net/getservent.c @@ -27,6 +27,7 @@ */ #include #include +#include #include #include "servent.h" #include "services.h" @@ -54,6 +55,7 @@ getservent_r( res_static rs ) int namelen; int nn,count; int total = 0; + int port; char* p2; p = rs->servent_ptr; @@ -92,9 +94,12 @@ getservent_r( res_static rs ) memcpy( rs->servent.s_name, p+1, namelen ); rs->servent.s_name[namelen] = 0; p += 1 + namelen; - rs->servent.s_port = ((((unsigned char*)p)[0] << 8) | - ((unsigned char*)p)[1]); + /* s_port must be in network byte order */ + port = ((((unsigned char*)p)[0] << 8) | + ((unsigned char*)p)[1]); + + rs->servent.s_port = htons(port); rs->servent.s_proto = p[2] == 't' ? "tcp" : "udp"; p += 4; /* skip port(2) + proto(1) + aliascount(1) */ -- cgit v1.1 From 1c8e10945eb1ab1352f73c7fb026b99397a8ca70 Mon Sep 17 00:00:00 2001 From: Iliyan Malchev Date: Wed, 20 May 2009 16:51:12 -0700 Subject: update msm_adsp.h header Signed-off-by: Iliyan Malchev --- libc/kernel/common/linux/msm_adsp.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'libc') diff --git a/libc/kernel/common/linux/msm_adsp.h b/libc/kernel/common/linux/msm_adsp.h index 6f12707..f6ab29d 100644 --- a/libc/kernel/common/linux/msm_adsp.h +++ b/libc/kernel/common/linux/msm_adsp.h @@ -14,7 +14,6 @@ #include #include -#include #define ADSP_IOCTL_MAGIC 'q' @@ -33,11 +32,6 @@ struct adsp_event_t { uint8_t *data; }; -struct adsp_pmem_info_t { - int fd; - void *vaddr; -}; - #define ADSP_IOCTL_ENABLE _IOR(ADSP_IOCTL_MAGIC, 1, unsigned) #define ADSP_IOCTL_DISABLE _IOR(ADSP_IOCTL_MAGIC, 2, unsigned) @@ -48,10 +42,22 @@ struct adsp_pmem_info_t { #define ADSP_IOCTL_GET_EVENT _IOWR(ADSP_IOCTL_MAGIC, 5, struct adsp_event_data_t *) +#define ADSP_IOCTL_SET_CLKRATE _IOR(ADSP_IOCTL_MAGIC, 6, unsigned) + #define ADSP_IOCTL_DISABLE_EVENT_RSP _IOR(ADSP_IOCTL_MAGIC, 10, unsigned) -#define ADSP_IOCTL_REGISTER_PMEM _IOW(ADSP_IOCTL_MAGIC, 13, struct adsp_pmem_info *) +struct adsp_pmem_info { + int fd; + void *vaddr; +}; + +#define ADSP_IOCTL_REGISTER_PMEM _IOW(ADSP_IOCTL_MAGIC, 13, unsigned) + +#define ADSP_IOCTL_UNREGISTER_PMEM _IOW(ADSP_IOCTL_MAGIC, 14, unsigned) #define ADSP_IOCTL_ABORT_EVENT_READ _IOW(ADSP_IOCTL_MAGIC, 15, unsigned) +#define ADSP_IOCTL_LINK_TASK _IOW(ADSP_IOCTL_MAGIC, 16, unsigned) + #endif + -- cgit v1.1 From 94a144eabd1c7477e77e81e83aa04d43c8a79791 Mon Sep 17 00:00:00 2001 From: Iliyan Malchev Date: Thu, 30 Apr 2009 12:29:52 -0700 Subject: add msm_camera.h header and .gitignore file to bionic Signed-off-by: Iliyan Malchev --- libc/kernel/common/media/msm_camera.h | 354 ++++++++++++++++++++++++++++++++++ 1 file changed, 354 insertions(+) create mode 100644 libc/kernel/common/media/msm_camera.h (limited to 'libc') diff --git a/libc/kernel/common/media/msm_camera.h b/libc/kernel/common/media/msm_camera.h new file mode 100644 index 0000000..750232e --- /dev/null +++ b/libc/kernel/common/media/msm_camera.h @@ -0,0 +1,354 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + **************************************************************************** + ****************************************************************************/ +#ifndef __LINUX_MSM_CAMERA_H +#define __LINUX_MSM_CAMERA_H + +#include +#include +#include + +#define MSM_CAM_IOCTL_MAGIC 'm' + +#define MSM_CAM_IOCTL_GET_SENSOR_INFO _IOR(MSM_CAM_IOCTL_MAGIC, 1, struct msm_camsensor_info_t *) + +#define MSM_CAM_IOCTL_REGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 2, struct msm_pmem_info_t *) + +#define MSM_CAM_IOCTL_UNREGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 3, unsigned) + +#define MSM_CAM_IOCTL_CTRL_COMMAND _IOW(MSM_CAM_IOCTL_MAGIC, 4, struct msm_ctrl_cmd_t *) + +#define MSM_CAM_IOCTL_CONFIG_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 5, struct msm_camera_vfe_cfg_cmd_t *) + +#define MSM_CAM_IOCTL_GET_STATS _IOR(MSM_CAM_IOCTL_MAGIC, 6, struct msm_camera_stats_event_ctrl_t *) + +#define MSM_CAM_IOCTL_GETFRAME _IOR(MSM_CAM_IOCTL_MAGIC, 7, struct msm_camera_get_frame_t *) + +#define MSM_CAM_IOCTL_ENABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 8, struct camera_enable_cmd_t *) + +#define MSM_CAM_IOCTL_CTRL_CMD_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 9, struct camera_cmd_t *) + +#define MSM_CAM_IOCTL_CONFIG_CMD _IOW(MSM_CAM_IOCTL_MAGIC, 10, struct camera_cmd_t *) + +#define MSM_CAM_IOCTL_DISABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 11, struct camera_enable_cmd_t *) + +#define MSM_CAM_IOCTL_PAD_REG_RESET2 _IOW(MSM_CAM_IOCTL_MAGIC, 12, struct camera_enable_cmd_t *) + +#define MSM_CAM_IOCTL_VFE_APPS_RESET _IOW(MSM_CAM_IOCTL_MAGIC, 13, struct camera_enable_cmd_t *) + +#define MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 14, struct camera_enable_cmd_t *) + +#define MSM_CAM_IOCTL_RELEASE_STATS_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 15, struct msm_stats_buf_t *) + +#define MSM_CAM_IOCTL_AXI_CONFIG _IOW(MSM_CAM_IOCTL_MAGIC, 16, struct msm_camera_vfe_cfg_cmd_t *) + +#define MSM_CAM_IOCTL_GET_PICTURE _IOW(MSM_CAM_IOCTL_MAGIC, 17, struct msm_camera_ctrl_cmd_t *) + +#define MSM_CAM_IOCTL_SET_CROP _IOW(MSM_CAM_IOCTL_MAGIC, 18, struct crop_info_t *) + +#define MSM_CAM_IOCTL_PICT_PP _IOW(MSM_CAM_IOCTL_MAGIC, 19, uint8_t *) + +#define MSM_CAM_IOCTL_PICT_PP_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 20, struct msm_snapshot_pp_status_t *) + +#define MSM_CAM_IOCTL_SENSOR_IO_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 21, struct sensor_cfg_data_t *) + +#define MSM_CAMERA_LED_OFF 0 +#define MSM_CAMERA_LED_LOW 1 +#define MSM_CAMERA_LED_HIGH 2 + +#define MSM_CAM_IOCTL_FLASH_LED_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 22, unsigned *) + +#define MSM_CAM_IOCTL_UNBLOCK_POLL_FRAME _IO(MSM_CAM_IOCTL_MAGIC, 23) + +#define MSM_CAM_IOCTL_CTRL_COMMAND_2 _IOW(MSM_CAM_IOCTL_MAGIC, 24, struct msm_ctrl_cmd_t *) + +#define MAX_SENSOR_NUM 3 +#define MAX_SENSOR_NAME 32 + +#define MSM_CAM_CTRL_CMD_DONE 0 +#define MSM_CAM_SENSOR_VFE_CMD 1 + +struct msm_ctrl_cmd_t { + uint16_t type; + uint16_t length; + void *value; + uint16_t status; + uint32_t timeout_ms; + int resp_fd; +}; + +struct msm_vfe_evt_msg_t { + unsigned short type; + unsigned short msg_id; + unsigned int len; + void *data; +}; + +#define MSM_CAM_RESP_CTRL 0 +#define MSM_CAM_RESP_STAT_EVT_MSG 1 +#define MSM_CAM_RESP_V4L2 2 +#define MSM_CAM_RESP_MAX 3 + +struct msm_stats_event_ctrl { + + int resptype; + int timeout_ms; + struct msm_ctrl_cmd_t ctrl_cmd; + + struct msm_vfe_evt_msg_t stats_event; +}; + +struct msm_camera_cfg_cmd_t { + + uint16_t cfg_type; + + uint16_t cmd_type; + uint16_t queue; + uint16_t length; + void *value; +}; + +#define CMD_GENERAL 0 +#define CMD_AXI_CFG_OUT1 1 +#define CMD_AXI_CFG_SNAP_O1_AND_O2 2 +#define CMD_AXI_CFG_OUT2 3 +#define CMD_PICT_T_AXI_CFG 4 +#define CMD_PICT_M_AXI_CFG 5 +#define CMD_RAW_PICT_AXI_CFG 6 +#define CMD_STATS_AXI_CFG 7 +#define CMD_STATS_AF_AXI_CFG 8 +#define CMD_FRAME_BUF_RELEASE 9 +#define CMD_PREV_BUF_CFG 10 +#define CMD_SNAP_BUF_RELEASE 11 +#define CMD_SNAP_BUF_CFG 12 +#define CMD_STATS_DISABLE 13 +#define CMD_STATS_ENABLE 14 +#define CMD_STATS_AF_ENABLE 15 +#define CMD_STATS_BUF_RELEASE 16 +#define CMD_STATS_AF_BUF_RELEASE 17 +#define UPDATE_STATS_INVALID 18 + +struct msm_vfe_cfg_cmd_t { + int cmd_type; + uint16_t length; + void *value; +}; + +#define MAX_CAMERA_ENABLE_NAME_LEN 32 +struct camera_enable_cmd_t { + char name[MAX_CAMERA_ENABLE_NAME_LEN]; +}; + +#define MSM_PMEM_OUTPUT1 0 +#define MSM_PMEM_OUTPUT2 1 +#define MSM_PMEM_OUTPUT1_OUTPUT2 2 +#define MSM_PMEM_THUMBAIL 3 +#define MSM_PMEM_MAINIMG 4 +#define MSM_PMEM_RAW_MAINIMG 5 +#define MSM_PMEM_AEC_AWB 6 +#define MSM_PMEM_AF 7 +#define MSM_PMEM_MAX 8 + +#define FRAME_PREVIEW_OUTPUT1 0 +#define FRAME_PREVIEW_OUTPUT2 1 +#define FRAME_SNAPSHOT 2 +#define FRAME_THUMBAIL 3 +#define FRAME_RAW_SNAPSHOT 4 +#define FRAME_MAX 5 + +struct msm_pmem_info_t { + int type; + int fd; + void *vaddr; + uint32_t y_off; + uint32_t cbcr_off; + uint8_t active; +}; + +struct outputCfg_t { + uint32_t height; + uint32_t width; + + uint32_t window_height_firstline; + uint32_t window_height_lastline; +}; + +#define OUTPUT_1 0 +#define OUTPUT_2 1 +#define OUTPUT_1_AND_2 2 +#define CAMIF_TO_AXI_VIA_OUTPUT_2 3 +#define OUTPUT_1_AND_CAMIF_TO_AXI_VIA_OUTPUT_2 4 +#define OUTPUT_2_AND_CAMIF_TO_AXI_VIA_OUTPUT_1 5 +#define LAST_AXI_OUTPUT_MODE_ENUM = OUTPUT_2_AND_CAMIF_TO_AXI_VIA_OUTPUT_1 6 + +#define MSM_FRAME_PREV_1 0 +#define MSM_FRAME_PREV_2 1 +#define MSM_FRAME_ENC 2 + +struct msm_frame_t { + int path; + unsigned long buffer; + uint32_t y_off; + uint32_t cbcr_off; + int fd; + + void *cropinfo; + int croplen; +}; + +#define STAT_AEAW 0 +#define STAT_AF 1 +#define STAT_MAX 2 + +struct msm_stats_buf_t { + int type; + unsigned long buffer; + int fd; +}; + +#define MSM_V4L2_VID_CAP_TYPE 0 +#define MSM_V4L2_STREAM_ON 1 +#define MSM_V4L2_STREAM_OFF 2 +#define MSM_V4L2_SNAPSHOT 3 +#define MSM_V4L2_QUERY_CTRL 4 +#define MSM_V4L2_GET_CTRL 5 +#define MSM_V4L2_SET_CTRL 6 +#define MSM_V4L2_QUERY 7 +#define MSM_V4L2_MAX 8 + +struct crop_info_t { + void *info; + int len; +}; + +struct msm_postproc_t { + int ftnum; + struct msm_frame_t fthumnail; + int fmnum; + struct msm_frame_t fmain; +}; + +struct msm_snapshot_pp_status_t { + void *status; +}; + +#define CFG_SET_MODE 0 +#define CFG_SET_EFFECT 1 +#define CFG_START 2 +#define CFG_PWR_UP 3 +#define CFG_PWR_DOWN 4 +#define CFG_WRITE_EXPOSURE_GAIN 5 +#define CFG_SET_DEFAULT_FOCUS 6 +#define CFG_MOVE_FOCUS 7 +#define CFG_REGISTER_TO_REAL_GAIN 8 +#define CFG_REAL_TO_REGISTER_GAIN 9 +#define CFG_SET_FPS 10 +#define CFG_SET_PICT_FPS 11 +#define CFG_SET_BRIGHTNESS 12 +#define CFG_SET_CONTRAST 13 +#define CFG_SET_ZOOM 14 +#define CFG_SET_EXPOSURE_MODE 15 +#define CFG_SET_WB 16 +#define CFG_SET_ANTIBANDING 17 +#define CFG_SET_EXP_GAIN 18 +#define CFG_SET_PICT_EXP_GAIN 19 +#define CFG_SET_LENS_SHADING 20 +#define CFG_GET_PICT_FPS 21 +#define CFG_GET_PREV_L_PF 22 +#define CFG_GET_PREV_P_PL 23 +#define CFG_GET_PICT_L_PF 24 +#define CFG_GET_PICT_P_PL 25 +#define CFG_GET_AF_MAX_STEPS 26 +#define CFG_GET_PICT_MAX_EXP_LC 27 +#define CFG_MAX 28 + +#define MOVE_NEAR 0 +#define MOVE_FAR 1 + +#define SENSOR_PREVIEW_MODE 0 +#define SENSOR_SNAPSHOT_MODE 1 +#define SENSOR_RAW_SNAPSHOT_MODE 2 + +#define SENSOR_QTR_SIZE 0 +#define SENSOR_FULL_SIZE 1 +#define SENSOR_INVALID_SIZE 2 + +#define CAMERA_EFFECT_OFF 0 +#define CAMERA_EFFECT_MONO 1 +#define CAMERA_EFFECT_NEGATIVE 2 +#define CAMERA_EFFECT_SOLARIZE 3 +#define CAMERA_EFFECT_PASTEL 4 +#define CAMERA_EFFECT_MOSAIC 5 +#define CAMERA_EFFECT_RESIZE 6 +#define CAMERA_EFFECT_SEPIA 7 +#define CAMERA_EFFECT_POSTERIZE 8 +#define CAMERA_EFFECT_WHITEBOARD 9 +#define CAMERA_EFFECT_BLACKBOARD 10 +#define CAMERA_EFFECT_AQUA 11 +#define CAMERA_EFFECT_MAX 12 + +struct sensor_pict_fps { + uint16_t prevfps; + uint16_t pictfps; +}; + +struct exp_gain_cfg { + uint16_t gain; + uint32_t line; +}; + +struct focus_cfg { + int32_t steps; + int dir; +}; + +struct fps_cfg { + uint16_t f_mult; + uint16_t fps_div; + uint32_t pict_fps_div; +}; + +struct sensor_cfg_data_t { + int cfgtype; + int mode; + int rs; + uint8_t max_steps; + + union { + int8_t effect; + uint8_t lens_shading; + uint16_t prevl_pf; + uint16_t prevp_pl; + uint16_t pictl_pf; + uint16_t pictp_pl; + uint32_t pict_max_exp_lc; + uint16_t p_fps; + struct sensor_pict_fps gfps; + struct exp_gain_cfg exp_gain; + struct focus_cfg focus; + struct fps_cfg fps; + } cfg; +}; + +#define GET_NAME 0 +#define GET_PREVIEW_LINE_PER_FRAME 1 +#define GET_PREVIEW_PIXELS_PER_LINE 2 +#define GET_SNAPSHOT_LINE_PER_FRAME 3 +#define GET_SNAPSHOT_PIXELS_PER_LINE 4 +#define GET_SNAPSHOT_FPS 5 +#define GET_SNAPSHOT_MAX_EP_LINE_CNT 6 + +struct msm_camsensor_info_t { + char name[MAX_SENSOR_NAME]; + uint8_t flash_enabled; +}; +#endif + -- cgit v1.1 From ca122b0e34df0e8c485be0d3ab1b80f728b76276 Mon Sep 17 00:00:00 2001 From: Dima Zavin Date: Wed, 27 May 2009 10:52:37 -0700 Subject: libc: Cleanup the libc makefile. Removes a lot of redundant code, and reorganizes the file. We first setup all the comomn variables we may need, and then define the actual libraries that need to be generated. Signed-off-by: Dima Zavin --- libc/Android.mk | 200 ++++++++++++++++++++++++-------------------------------- 1 file changed, 84 insertions(+), 116 deletions(-) (limited to 'libc') diff --git a/libc/Android.mk b/libc/Android.mk index 333dd1e..1c1b312 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -1,6 +1,9 @@ LOCAL_PATH:= $(call my-dir) include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk + +# Define the common source files for all the libc instances +# ========================================================= libc_common_src_files := \ $(syscall_src) \ unistd/abort.c \ @@ -272,6 +275,8 @@ libc_common_src_files := \ netbsd/nameser/ns_print.c \ netbsd/nameser/ns_samedomain.c +# Architecture specific source files go here +# ========================================================= ifeq ($(TARGET_ARCH),arm) libc_common_src_files += \ bionic/eabi.c \ @@ -301,6 +306,14 @@ libc_common_src_files += \ bionic/pthread.c.arm \ bionic/pthread-timers.c.arm \ bionic/ptrace.c.arm + +# these are used by the static and dynamic versions of the libc +# respectively +libc_arch_static_src_files := \ + arch-arm/bionic/exidx_static.c + +libc_arch_dynamic_src_files := \ + arch-arm/bionic/exidx_dynamic.c else # !arm ifeq ($(TARGET_ARCH),x86) @@ -322,10 +335,17 @@ libc_common_src_files += \ bionic/pthread.c \ bionic/pthread-timers.c \ bionic/ptrace.c -endif # x86 +# this is needed for static versions of libc +libc_arch_static_src_files := \ + arch-x86/bionic/dl_iterate_phdr_static.c + +libc_arch_dynamic_src_files := +endif # x86 endif # !arm +# Define some common cflags +# ======================================================== libc_common_cflags := \ -DWITH_ERRLIST \ -DANDROID_CHANGES \ @@ -337,6 +357,7 @@ libc_common_cflags := \ -DNEED_PSELECT=1 \ -DINET6 \ -I$(LOCAL_PATH)/private \ + -DUSE_DL_PREFIX ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true) libc_common_cflags += -DDEBUG @@ -344,155 +365,124 @@ endif ifeq ($(TARGET_ARCH),arm) libc_common_cflags += -fstrict-aliasing -endif + libc_crt_target_cflags := -mthumb-interwork +else # !arm + ifeq ($(TARGET_ARCH),x86) + libc_crt_target_cflags := -m32 + endif # x86 +endif # !arm +# Define some common includes +# ======================================================== libc_common_c_includes := \ $(LOCAL_PATH)/stdlib \ $(LOCAL_PATH)/string \ $(LOCAL_PATH)/stdio -# libc_common.a -# ======================================================== -include $(CLEAR_VARS) +# Define the libc run-time (crt) support object files that must be built, +# which are needed to build all other objects (shared/static libs and +# executables) +# ========================================================================== -LOCAL_SRC_FILES := $(libc_common_src_files) -LOCAL_CFLAGS := $(libc_common_cflags) -DUSE_DL_PREFIX -LOCAL_C_INCLUDES := $(libc_common_c_includes) - -ifneq ($(TARGET_SIMULATOR),true) - ifeq ($(TARGET_ARCH),arm) - crtend_target_cflags := -mthumb-interwork - else - ifeq ($(TARGET_ARCH),x86) - crtend_target_cflags := -m32 - endif - endif -# We rename crtend.o to crtend_android.o to avoid a -# name clash between gcc and bionic. -GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o -$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S +ifeq ($(TARGET_ARCH),x86) +# we only need begin_so/end_so for x86, since it needs an appropriate .init +# section in the shared library with a function to call all the entries in +# .ctors section. ARM uses init_array, and does not need the function. +GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o +$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S @mkdir -p $(dir $@) - $(TARGET_CC) $(crtend_target_cflags) -o $@ -c $< + $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $< ALL_GENERATED_SOURCES += $(GEN) -endif - -# crtbegin_so.o/crtend_so.o -# These are needed for building the shared libs. -ifneq ($(TARGET_SIMULATOR),true) +GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o +$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S + @mkdir -p $(dir $@) + $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $< +ALL_GENERATED_SOURCES += $(GEN) +endif # TARGET_ARCH == x86 -ifeq ($(TARGET_ARCH),x86) -crt_begin_end_so_target_cflags := -m32 +GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o +$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S + @mkdir -p $(dir $@) + $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $< +ALL_GENERATED_SOURCES += $(GEN) -GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o -$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S +GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o +$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S @mkdir -p $(dir $@) - $(TARGET_CC) $(crt_begin_end_so_target_cflags) -o $@ -c $< + $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $< ALL_GENERATED_SOURCES += $(GEN) -GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o -$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S + +# We rename crtend.o to crtend_android.o to avoid a +# name clash between gcc and bionic. +GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o +$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S @mkdir -p $(dir $@) - $(TARGET_CC) $(crt_begin_end_so_target_cflags) -o $@ -c $< + $(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $< ALL_GENERATED_SOURCES += $(GEN) -endif # TARGET_ARCH == x86 -endif # !TARGET_SIMULATOR +# To enable malloc leak check for statically linked programs, add +# "WITH_MALLOC_CHECK_LIBC_A := true" to buildspec.mk +WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A)) +# ======================================================== +# libc_common.a +# ======================================================== +include $(CLEAR_VARS) +LOCAL_SRC_FILES := $(libc_common_src_files) +LOCAL_CFLAGS := $(libc_common_cflags) +LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_MODULE := libc_common LOCAL_SYSTEM_SHARED_LIBRARIES := include $(BUILD_STATIC_LIBRARY) +# ======================================================== # libc.a # ======================================================== - include $(CLEAR_VARS) -include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk - -# To enable malloc leak check for statically linked programs, add -# "WITH_MALLOC_CHECK_LIBC_A := true" to device/buildspec.mk -WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A)) - LOCAL_SRC_FILES := \ - $(libc_common_src_files) \ + $(libc_arch_static_src_files) \ bionic/dlmalloc.c \ bionic/libc_init_static.c +LOCAL_CFLAGS := $(libc_common_cflags) + ifeq ($(WITH_MALLOC_CHECK_LIBC_A),true) + LOCAL_CFLAGS += -DMALLOC_LEAK_CHECK LOCAL_SRC_FILES += bionic/malloc_leak.c.arm endif -ifeq ($(TARGET_ARCH),arm) -LOCAL_SRC_FILES += \ - arch-arm/bionic/exidx_static.c - -else # TARGET_ARCH != arm - -ifeq ($(TARGET_ARCH),x86) -LOCAL_SRC_FILES += \ - arch-x86/bionic/dl_iterate_phdr_static.c -endif - -endif - -ifneq ($(TARGET_SIMULATOR),true) - ifeq ($(TARGET_ARCH),arm) - crtbegin_static_target_cflags := -mthumb-interwork - else - ifeq ($(TARGET_ARCH),x86) - crtbegin_static_target_cflags := -m32 - endif - endif -GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o -$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S - @mkdir -p $(dir $@) - $(TARGET_CC) $(crtbegin_static_target_cflags) -o $@ -c $< -ALL_GENERATED_SOURCES += $(GEN) -endif - -LOCAL_CFLAGS := $(libc_common_cflags) - LOCAL_C_INCLUDES := $(libc_common_c_includes) -ifeq ($(WITH_MALLOC_CHECK_LIBC_A),true) - LOCAL_CFLAGS += -DUSE_DL_PREFIX -DMALLOC_LEAK_CHECK -endif - +LOCAL_MODULE := libc LOCAL_WHOLE_STATIC_LIBRARIES := libc_common -LOCAL_MODULE:= libc LOCAL_SYSTEM_SHARED_LIBRARIES := include $(BUILD_STATIC_LIBRARY) +# ======================================================== # libc.so # ======================================================== - include $(CLEAR_VARS) LOCAL_CFLAGS := $(libc_common_cflags) - -LOCAL_CFLAGS += -DUSE_DL_PREFIX - LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_SRC_FILES := \ + $(libc_arch_dynamic_src_files) \ bionic/dlmalloc.c \ bionic/malloc_leak.c.arm \ bionic/libc_init_dynamic.c -ifeq ($(TARGET_ARCH),arm) -LOCAL_SRC_FILES += \ - arch-arm/bionic/exidx_dynamic.c -endif - LOCAL_MODULE:= libc # WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries, @@ -507,45 +497,26 @@ LOCAL_SHARED_LIBRARIES := libdl LOCAL_WHOLE_STATIC_LIBRARIES := libc_common LOCAL_SYSTEM_SHARED_LIBRARIES := -ifneq ($(TARGET_SIMULATOR),true) - ifeq ($(TARGET_ARCH),arm) - crtbegin_dynamic_target_cflags := -mthumb-interwork - else - ifeq ($(TARGET_ARCH),x86) - crtbegin_dynamic_target_cflags := -m32 - endif - endif -GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o -$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S - @mkdir -p $(dir $@) - $(TARGET_CC) $(crtbegin_dynamic_target_cflags) -o $@ -c $< -ALL_GENERATED_SOURCES += $(GEN) -endif - include $(BUILD_SHARED_LIBRARY) +# ======================================================== # libc_debug.so # ======================================================== - include $(CLEAR_VARS) -LOCAL_CFLAGS := $(libc_common_cflags) - -LOCAL_CFLAGS += -DUSE_DL_PREFIX -DMALLOC_LEAK_CHECK +LOCAL_CFLAGS := \ + $(libc_common_cflags) \ + -DMALLOC_LEAK_CHECK LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_SRC_FILES := \ + $(libc_arch_dynamic_src_files) \ bionic/dlmalloc.c \ bionic/malloc_leak.c.arm \ bionic/libc_init_dynamic.c -ifeq ($(TARGET_ARCH),arm) -LOCAL_SRC_FILES += \ - arch-arm/bionic/exidx_dynamic.c -endif - LOCAL_MODULE:= libc_debug # WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries, @@ -564,9 +535,6 @@ LOCAL_PRELINK_MODULE := false # Don't install on release build LOCAL_MODULE_TAGS := eng -GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o -ALL_GENERATED_SOURCES += $(GEN) - include $(BUILD_SHARED_LIBRARY) # ======================================================== -- cgit v1.1 From 49e55332784b82f7112ee7c1ea3c176c9dc32d7a Mon Sep 17 00:00:00 2001 From: Dima Zavin Date: Wed, 27 May 2009 10:52:37 -0700 Subject: libc: Add an intermediate version of the static libc without malloc For now, this will only used by the dynamic loader to ensure that malloc and friends are never called. Signed-off-by: Dima Zavin --- libc/Android.mk | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'libc') diff --git a/libc/Android.mk b/libc/Android.mk index 1c1b312..59a4c6b 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -444,6 +444,32 @@ include $(BUILD_STATIC_LIBRARY) # ======================================================== +# libc_nomalloc.a +# ======================================================== +# +# This is a version of the static C library that does not +# include malloc. It's useful in situations when calling +# the user wants to provide their own malloc implementation, +# or wants to explicitly disallow the use of the use of malloc, +# like the dynamic loader. + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + $(libc_arch_static_src_files) \ + bionic/libc_init_static.c + +LOCAL_C_INCLUDES := $(libc_common_c_includes) +LOCAL_CFLAGS := $(libc_common_cflags) + +LOCAL_MODULE := libc_nomalloc +LOCAL_WHOLE_STATIC_LIBRARIES := libc_common +LOCAL_SYSTEM_SHARED_LIBRARIES := + +include $(BUILD_STATIC_LIBRARY) + + +# ======================================================== # libc.a # ======================================================== include $(CLEAR_VARS) -- cgit v1.1 From 03eabfe65e1e2c36f4d26c78a730fa19a3bdada3 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Thu, 28 May 2009 15:54:03 +0200 Subject: Fix the C library initialization to avoid calling static C++ constructors twice. The problem was due to the fact that, in the case of dynamic executables, the dynamic linker calls the DT_PREINIT_ARRAY, DT_INIT and DT_INIT_ARRAY constructors when loading shared libraries and dynamic executables, *before* calling the executable's entry point (i.e. arch-$ARCH/bionic/crtbegin_dynamic.c) which in turns call __libc_init() in libc.so, as defined by bionic/libc_init_dynamic.c The latter did call these constructors array again, mistakenly. The patch also updates the documentation of many related functions. Also adds a new section to linker/README.TXT explaining restrictions on C library usage. The patch has been tested on a Dream for stability issues with proprietary blobs: - H264 decoding works - Camera + Video recording works - GPS works - Sensors work The tests in system/extra/tests/bionic/libc/common/test_static_cpp_mutex.cpp has been run and shows the static C++ constructor being called only once. --- libc/arch-arm/bionic/crtbegin_dynamic.S | 26 +++++--- libc/arch-arm/bionic/crtbegin_static.S | 33 +++++---- libc/arch-x86/bionic/crtbegin_dynamic.S | 24 +++++-- libc/arch-x86/bionic/crtbegin_static.S | 24 ++++--- libc/bionic/libc_init_common.c | 58 +++++++--------- libc/bionic/libc_init_dynamic.c | 40 ++++++++--- libc/bionic/libc_init_static.c | 37 ++++++---- libc/bionic/pthread_internal.h | 115 -------------------------------- libc/private/bionic_preinit.h | 76 +++++++++++++++++++++ libc/private/pthread_internal.h | 115 ++++++++++++++++++++++++++++++++ 10 files changed, 342 insertions(+), 206 deletions(-) delete mode 100644 libc/bionic/pthread_internal.h create mode 100644 libc/private/bionic_preinit.h create mode 100644 libc/private/pthread_internal.h (limited to 'libc') diff --git a/libc/arch-arm/bionic/crtbegin_dynamic.S b/libc/arch-arm/bionic/crtbegin_dynamic.S index e265923..624d611 100644 --- a/libc/arch-arm/bionic/crtbegin_dynamic.S +++ b/libc/arch-arm/bionic/crtbegin_dynamic.S @@ -30,25 +30,35 @@ .type _start,#function .globl _start -# this is the small startup code that is first run when -# any executable that is statically-linked with Bionic -# runs. +# This is the small startup code that is called from +# the dynamic linker to execute an executable once all +# dependent shared libraries have been loaded and +# initialized. # -# it's purpose is to call __libc_init with appropriate +# It's purpose is to call __libc_init as defined in +# bionic/libc_init_dynamic.c with appropriate # arguments, which are: # # - the address of the raw data block setup by the Linux # kernel ELF loader # -# - address of an "onexit" function, not used on any -# platform supported by Bionic +# - address of an "onexit" function (not used on any +# platform supported by Bionic) # # - address of the "main" function of the program. We # can't hard-code it in the adr pseudo instruction # so we use a tiny trampoline that will get relocated # by the dynamic linker before this code runs # -# - address of the constructor list +# - address of the constructors table, i.e. a table +# that points to various initialization and +# finalization sections for the program. +# +# NOTE: This code is currently placed in shared libraries +# by the build system, but will be ignored. +# +# On the other hand, the arrays defined below are +# required and will be parsed by the dynamic linker. # _start: mov r0, sp @@ -63,7 +73,7 @@ _start: .long __INIT_ARRAY__ .long __FINI_ARRAY__ .long __CTOR_LIST__ - + # the .ctors section contains a list of pointers to "constructor" # functions that need to be called in order during C library initialization, # just before the program is being run. This is a C++ requirement diff --git a/libc/arch-arm/bionic/crtbegin_static.S b/libc/arch-arm/bionic/crtbegin_static.S index e265923..69d8df6 100644 --- a/libc/arch-arm/bionic/crtbegin_static.S +++ b/libc/arch-arm/bionic/crtbegin_static.S @@ -30,25 +30,27 @@ .type _start,#function .globl _start -# this is the small startup code that is first run when -# any executable that is statically-linked with Bionic -# runs. +# This is the small startup code that is first run when +# any static executable runs. A static executable is one +# that is started directly by the Linux kernel, not from +# the dynamic linker, it thus cannot depend on any shared +# library. # -# it's purpose is to call __libc_init with appropriate +# It's purpose is to call __libc_init as defined in +# bionic/libc_init_static.c with appropriate # arguments, which are: # # - the address of the raw data block setup by the Linux # kernel ELF loader # -# - address of an "onexit" function, not used on any -# platform supported by Bionic +# - address of an "onexit" function (not used on any +# platform supported by Bionic). # -# - address of the "main" function of the program. We -# can't hard-code it in the adr pseudo instruction -# so we use a tiny trampoline that will get relocated -# by the dynamic linker before this code runs +# - address of the "main" function of the program. # -# - address of the constructor list +# - address of the constructors table, i.e. a table +# that points to various initialization and +# finalization sections for the program. # _start: mov r0, sp @@ -59,11 +61,18 @@ _start: 0: b main +# The "C++ ABI for ARM" document that static C++ constructors +# shall only be called from the .init_array section. +# +# Do we really need a .ctors section on ARM platforms ? +# It looks like it will always be empty. +# + 1: .long __PREINIT_ARRAY__ .long __INIT_ARRAY__ .long __FINI_ARRAY__ .long __CTOR_LIST__ - + # the .ctors section contains a list of pointers to "constructor" # functions that need to be called in order during C library initialization, # just before the program is being run. This is a C++ requirement diff --git a/libc/arch-x86/bionic/crtbegin_dynamic.S b/libc/arch-x86/bionic/crtbegin_dynamic.S index 3b47b18..b013641 100644 --- a/libc/arch-x86/bionic/crtbegin_dynamic.S +++ b/libc/arch-x86/bionic/crtbegin_dynamic.S @@ -29,25 +29,35 @@ .type _start, @function .globl _start -# this is the small startup code that is first run when -# any executable that is statically-linked with Bionic -# runs. +# This is the small startup code that is called from +# the dynamic linker to execute an executable once all +# dependent shared libraries have been loaded and +# initialized. # -# it's purpose is to call __libc_init with appropriate +# It's purpose is to call __libc_init as defined in +# bionic/libc_init_dynamic.c with appropriate # arguments, which are: # # - the address of the raw data block setup by the Linux # kernel ELF loader # -# - address of an "onexit" function, not used on any -# platform supported by Bionic +# - address of an "onexit" function (not used on any +# platform supported by Bionic) # # - address of the "main" function of the program. We # can't hard-code it in the adr pseudo instruction # so we use a tiny trampoline that will get relocated # by the dynamic linker before this code runs # -# - address of the constructor list +# - address of the constructors table, i.e. a table +# that points to various initialization and +# finalization sections for the program. +# +# NOTE: This code is currently placed in shared libraries +# by the build system, but will be ignored. +# +# On the other hand, the arrays defined below are +# required and will be parsed by the dynamic linker. # _start: mov %esp, %eax diff --git a/libc/arch-x86/bionic/crtbegin_static.S b/libc/arch-x86/bionic/crtbegin_static.S index eb4acee..a6c9ebf 100644 --- a/libc/arch-x86/bionic/crtbegin_static.S +++ b/libc/arch-x86/bionic/crtbegin_static.S @@ -29,25 +29,27 @@ .type _start, @function .globl _start -# this is the small startup code that is first run when -# any executable that is statically-linked with Bionic -# runs. +# This is the small startup code that is first run when +# any static executable runs. A static executable is one +# that is started directly by the Linux kernel, not from +# the dynamic linker, it thus cannot depend on any shared +# library. # -# it's purpose is to call __libc_init with appropriate +# It's purpose is to call __libc_init as defined in +# bionic/libc_init_static.c with appropriate # arguments, which are: # # - the address of the raw data block setup by the Linux # kernel ELF loader # -# - address of an "onexit" function, not used on any -# platform supported by Bionic +# - address of an "onexit" function (not used on any +# platform supported by Bionic). # -# - address of the "main" function of the program. We -# can't hard-code it in the adr pseudo instruction -# so we use a tiny trampoline that will get relocated -# by the dynamic linker before this code runs +# - address of the "main" function of the program. # -# - address of the constructor list +# - address of the constructors table, i.e. a table +# that points to various initialization and +# finalization sections for the program. # _start: mov %esp, %eax diff --git a/libc/bionic/libc_init_common.c b/libc/bionic/libc_init_common.c index de4919d..523afcf 100644 --- a/libc/bionic/libc_init_common.c +++ b/libc/bionic/libc_init_common.c @@ -39,8 +39,11 @@ #include #include -extern void _init(void); -extern void _fini(void); +/* This contains the common C library initialization code. + * To understand what happens here, you should read the + * "Initialization and Finalization" section of the file + * named bionic/linker/README.TXT + */ static void call_array(void(**list)()) { @@ -50,15 +53,6 @@ static void call_array(void(**list)()) } } -static void __bionic_do_global_dtors(structors_array_t const * const p) -{ - call_array(p->fini_array); - //_fini(); -} - -extern unsigned __get_sp(void); -extern pid_t gettid(void); - char* __progname; char **environ; @@ -69,30 +63,28 @@ unsigned int __page_shift = PAGE_SHIFT; int __system_properties_init(void); +/* This function can be run under two different contexts: + * + * - for statically linked executables (i.e. those who do + * not depend on shared libraries at all), it will be + * called from the __libc_init() function defined in + * bionic/libc_init_static.c + * + * - for dynamic executables, it will be called from the + * __libc_init() function defined in bionic/libc_init_dynamic.c + * + */ void __libc_init_common(uintptr_t *elfdata, void (*onexit)(void), int (*slingshot)(int, char**, char**), structors_array_t const * const structors, void (*pre_ctor_hook)()) { - pthread_internal_t thread; - pthread_attr_t thread_attr; - void *tls_area[BIONIC_TLS_SLOTS]; int argc; char **argv, **envp, **envend; struct auxentry *auxentry; unsigned int page_size = 0, page_shift = 0; - /* The main thread's stack has empirically shown to be 84k */ - unsigned stacktop = (__get_sp() & ~(PAGE_SIZE - 1)) + PAGE_SIZE; - unsigned stacksize = 128 * 1024; //84 * 1024; - unsigned stackbottom = stacktop - stacksize; - - pthread_attr_init(&thread_attr); - pthread_attr_setstack(&thread_attr, (void*)stackbottom, stacksize); - _init_thread(&thread, gettid(), &thread_attr, (void*)stackbottom); - __init_tls(tls_area, &thread); - argc = (int) *elfdata++; argv = (char**) elfdata; envp = argv+(argc+1); @@ -106,17 +98,17 @@ void __libc_init_common(uintptr_t *elfdata, if (pre_ctor_hook) pre_ctor_hook(); - // XXX: we should execute the .fini_array upon exit - - // pre-init array. - // XXX: I'm not sure what's the different with the init array. - call_array(structors->preinit_array); + if (structors != NULL) { + // pre-init array. + call_array(structors->preinit_array); - // for compatibility with non-eabi binary, call the .ctors section - call_array(structors->ctors_array); + // for compatibility with non-eabi binary, call the .ctors section + // this is only useful for static non-ARM (e.g. x86) executables. + call_array(structors->ctors_array); - // call static constructors - call_array(structors->init_array); + // call static constructors + call_array(structors->init_array); + } exit(slingshot(argc, argv, envp)); } diff --git a/libc/bionic/libc_init_dynamic.c b/libc/bionic/libc_init_dynamic.c index 8cf24b4..e1ff13d 100644 --- a/libc/bionic/libc_init_dynamic.c +++ b/libc/bionic/libc_init_dynamic.c @@ -25,18 +25,29 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + /* * libc_init_static.c * - * This function takes the raw data block set up by the ELF loader - * in the kernel and parses it. It is invoked by crt0.S which makes - * any necessary adjustments and passes calls this function using - * the standard C calling convention. + * This function is called for dynamic executables after the dynamic + * linker has loaded and initialized all dependent shared libraries. + * + * It takes the raw data block set up by the ELF loader + * in the kernel and parses it. * * The arguments are: - * uintptr_t *elfdata -- The ELF loader data block; usually from the stack. - * Basically a pointer to argc. - * void (*onexit)(void) -- Function to install into onexit + * elfdata -- The ELF loader data block; usually from the stack. + * Basically a pointer to argc. + * + * onexit -- Function to call on exit, can be NULL. + * + * slingshot -- Address of the program's main function + * + * structors -- Table of constructor functions arrays that must + * be called before the slingshot. + * + * It is called from the assembly fragment found in + * arch-$ARCH/bionic/crtbegin_dynamic.S */ /* @@ -62,5 +73,18 @@ __noreturn void __libc_init(uintptr_t *elfdata, int (*slingshot)(int, char**, char**), structors_array_t const * const structors) { - __libc_init_common(elfdata, onexit, slingshot, structors, malloc_debug_init); + /* NOTE: At this point, the dynamic linker has *already* called + * all initializers properly, so we ignore 'structors' to + * avoid calling them twice. + */ + + /* NOTE2: Is it worthwhile to use malloc_debug_init() in the case of + * of the non-debug shared C library ? + * + * The implementation in bionic/malloc_leak.c contains a lot + * of code which will turn to be unused, and we add a dispatch + * overhead to malloc() et al. that proved to be significant + * in the past (e.g. making boot sequence 5% slower) + */ + __libc_init_common(elfdata, onexit, slingshot, NULL, malloc_debug_init); } diff --git a/libc/bionic/libc_init_static.c b/libc/bionic/libc_init_static.c index ec463f7..d7af640 100644 --- a/libc/bionic/libc_init_static.c +++ b/libc/bionic/libc_init_static.c @@ -25,18 +25,30 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + /* * libc_init_static.c * - * This function takes the raw data block set up by the ELF loader - * in the kernel and parses it. It is invoked by crt0.S which makes - * any necessary adjustments and passes calls this function using - * the standard C calling convention. + * This function is called for static executables, i.e. those that + * dont depend on shared libraries and are directly started by the + * Linux kernel. + * + * It takes the raw data block set up by the ELF loader + * in the kernel and parses it. * * The arguments are: - * uintptr_t *elfdata -- The ELF loader data block; usually from the stack. - * Basically a pointer to argc. - * void (*onexit)(void) -- Function to install into onexit + * elfdata -- The ELF loader data block; usually from the stack. + * Basically a pointer to argc. + * + * onexit -- Function to call on exit, can be NULL. + * + * slingshot -- Address of the program's main function + * + * structors -- Table of constructor functions arrays that must + * be called before the slingshot. + * + * It is called from the assembly fragment found in + * arch-$ARCH/bionic/crtbegin_static.S */ /* @@ -51,18 +63,19 @@ #include #include #include -#include "pthread_internal.h" -#include "atexit.h" +#include "bionic_preinit.h" #include "libc_init_common.h" -#include -#include - __noreturn void __libc_init(uintptr_t *elfdata, void (*onexit)(void), int (*slingshot)(int, char**, char**), structors_array_t const * const structors) { + pthread_internal_t thread; + void *tls_area[BIONIC_TLS_SLOTS]; + + __libc_preinit( &thread, tls_area ); + /* * To enable malloc checks for statically linked programs, add * "WITH_MALLOC_CHECK_LIBC_A := true" in device/buildspec.mk diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h deleted file mode 100644 index eb4e80c..0000000 --- a/libc/bionic/pthread_internal.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#ifndef _PTHREAD_INTERNAL_H_ -#define _PTHREAD_INTERNAL_H_ - -#include - -__BEGIN_DECLS - -typedef struct pthread_internal_t -{ - struct pthread_internal_t* next; - struct pthread_internal_t** pref; - pthread_attr_t attr; - pid_t kernel_id; - pthread_cond_t join_cond; - int join_count; - void* return_value; - int intern; - __pthread_cleanup_t* cleanup_stack; - void** tls; /* thread-local storage area */ -} pthread_internal_t; - -extern void _init_thread(pthread_internal_t * thread, pid_t kernel_id, pthread_attr_t * attr, void * stack_base); - -/* needed by posix-timers.c */ - -static __inline__ void timespec_add( struct timespec* a, const struct timespec* b ) -{ - a->tv_sec += b->tv_sec; - a->tv_nsec += b->tv_nsec; - if (a->tv_nsec >= 1000000000) { - a->tv_nsec -= 1000000000; - a->tv_sec += 1; - } -} - -static __inline__ void timespec_sub( struct timespec* a, const struct timespec* b ) -{ - a->tv_sec -= b->tv_sec; - a->tv_nsec -= b->tv_nsec; - if (a->tv_nsec < 0) { - a->tv_nsec += 1000000000; - a->tv_sec -= 1; - } -} - -static __inline__ void timespec_zero( struct timespec* a ) -{ - a->tv_sec = a->tv_nsec = 0; -} - -static __inline__ int timespec_is_zero( const struct timespec* a ) -{ - return (a->tv_sec == 0 && a->tv_nsec == 0); -} - -static __inline__ int timespec_cmp( const struct timespec* a, const struct timespec* b ) -{ - if (a->tv_sec < b->tv_sec) return -1; - if (a->tv_sec > b->tv_sec) return +1; - if (a->tv_nsec < b->tv_nsec) return -1; - if (a->tv_nsec > b->tv_nsec) return +1; - return 0; -} - -static __inline__ int timespec_cmp0( const struct timespec* a ) -{ - if (a->tv_sec < 0) return -1; - if (a->tv_sec > 0) return +1; - if (a->tv_nsec < 0) return -1; - if (a->tv_nsec > 0) return +1; - return 0; -} - -extern int __pthread_cond_timedwait(pthread_cond_t*, - pthread_mutex_t*, - const struct timespec*, - clockid_t); - -extern int __pthread_cond_timedwait_relative(pthread_cond_t*, - pthread_mutex_t*, - const struct timespec*); - -/* needed by fork.c */ -extern void __timer_table_start_stop(int stop); - -__END_DECLS - -#endif /* _PTHREAD_INTERNAL_H_ */ diff --git a/libc/private/bionic_preinit.h b/libc/private/bionic_preinit.h new file mode 100644 index 0000000..b74a8b4 --- /dev/null +++ b/libc/private/bionic_preinit.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _BIONIC_PREINIT_H +#define _BIONIC_PREINIT_H + +#include "pthread_internal.h" +#include "bionic_tls.h" +#include + +/* this function is used to perform a minimal initialization of the + * the C library. This must be performed before any other call to + * other functions, in either the dynamic linker's startup code + * or libc_init_static.c + * + * 'main_thread' and 'tls_area' must be persistent variables, + * which means they must be either global, or allocated in the + * main thread's stack frame and never, ever, freed before + * program exit. + * + * VERY IMPORTANT NOTE: + * + * THIS IMPLEMENTATION SHOULD NOT USE GLOBAL VARIABLES. + * + * The reason is the dynamic linker's tricky usage of C library + * functions and later renaming of their symbols. See the + * "C Library Usage Restriction" section in bionic/linker/README.TXT + * for details. + */ + +extern unsigned __get_sp(void); +extern pid_t gettid(void); + +static __inline__ void +__libc_preinit( pthread_internal_t* main_thread, + void* tls_area[BIONIC_TLS_SLOTS] ) +{ + pthread_attr_t thread_attr; + + /* Setup the main thread's information */ + unsigned stacktop = (__get_sp() & ~(PAGE_SIZE - 1)) + PAGE_SIZE; + unsigned stacksize = 128 * 1024; + unsigned stackbottom = stacktop - stacksize; + + pthread_attr_init(&thread_attr); + pthread_attr_setstack(&thread_attr, (void*)stackbottom, stacksize); + _init_thread(main_thread, gettid(), &thread_attr, (void*)stackbottom); + __init_tls(tls_area, main_thread); +} + +#endif /* _BIONIC_INIT_H */ diff --git a/libc/private/pthread_internal.h b/libc/private/pthread_internal.h new file mode 100644 index 0000000..eb4e80c --- /dev/null +++ b/libc/private/pthread_internal.h @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef _PTHREAD_INTERNAL_H_ +#define _PTHREAD_INTERNAL_H_ + +#include + +__BEGIN_DECLS + +typedef struct pthread_internal_t +{ + struct pthread_internal_t* next; + struct pthread_internal_t** pref; + pthread_attr_t attr; + pid_t kernel_id; + pthread_cond_t join_cond; + int join_count; + void* return_value; + int intern; + __pthread_cleanup_t* cleanup_stack; + void** tls; /* thread-local storage area */ +} pthread_internal_t; + +extern void _init_thread(pthread_internal_t * thread, pid_t kernel_id, pthread_attr_t * attr, void * stack_base); + +/* needed by posix-timers.c */ + +static __inline__ void timespec_add( struct timespec* a, const struct timespec* b ) +{ + a->tv_sec += b->tv_sec; + a->tv_nsec += b->tv_nsec; + if (a->tv_nsec >= 1000000000) { + a->tv_nsec -= 1000000000; + a->tv_sec += 1; + } +} + +static __inline__ void timespec_sub( struct timespec* a, const struct timespec* b ) +{ + a->tv_sec -= b->tv_sec; + a->tv_nsec -= b->tv_nsec; + if (a->tv_nsec < 0) { + a->tv_nsec += 1000000000; + a->tv_sec -= 1; + } +} + +static __inline__ void timespec_zero( struct timespec* a ) +{ + a->tv_sec = a->tv_nsec = 0; +} + +static __inline__ int timespec_is_zero( const struct timespec* a ) +{ + return (a->tv_sec == 0 && a->tv_nsec == 0); +} + +static __inline__ int timespec_cmp( const struct timespec* a, const struct timespec* b ) +{ + if (a->tv_sec < b->tv_sec) return -1; + if (a->tv_sec > b->tv_sec) return +1; + if (a->tv_nsec < b->tv_nsec) return -1; + if (a->tv_nsec > b->tv_nsec) return +1; + return 0; +} + +static __inline__ int timespec_cmp0( const struct timespec* a ) +{ + if (a->tv_sec < 0) return -1; + if (a->tv_sec > 0) return +1; + if (a->tv_nsec < 0) return -1; + if (a->tv_nsec > 0) return +1; + return 0; +} + +extern int __pthread_cond_timedwait(pthread_cond_t*, + pthread_mutex_t*, + const struct timespec*, + clockid_t); + +extern int __pthread_cond_timedwait_relative(pthread_cond_t*, + pthread_mutex_t*, + const struct timespec*); + +/* needed by fork.c */ +extern void __timer_table_start_stop(int stop); + +__END_DECLS + +#endif /* _PTHREAD_INTERNAL_H_ */ -- cgit v1.1 From 3a654b1e04d4275ae315cfe1b196998acf10052c Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Wed, 3 Jun 2009 19:32:37 +0200 Subject: Revert "Fix the C library initialization to avoid calling static C++ constructors twice." This reverts commit 03eabfe65e1e2c36f4d26c78a730fa19a3bdada3. --- libc/arch-arm/bionic/crtbegin_dynamic.S | 26 +++----- libc/arch-arm/bionic/crtbegin_static.S | 33 ++++----- libc/arch-x86/bionic/crtbegin_dynamic.S | 24 ++----- libc/arch-x86/bionic/crtbegin_static.S | 24 +++---- libc/bionic/libc_init_common.c | 58 +++++++++------- libc/bionic/libc_init_dynamic.c | 40 +++-------- libc/bionic/libc_init_static.c | 37 ++++------ libc/bionic/pthread_internal.h | 115 ++++++++++++++++++++++++++++++++ libc/private/bionic_preinit.h | 76 --------------------- libc/private/pthread_internal.h | 115 -------------------------------- 10 files changed, 206 insertions(+), 342 deletions(-) create mode 100644 libc/bionic/pthread_internal.h delete mode 100644 libc/private/bionic_preinit.h delete mode 100644 libc/private/pthread_internal.h (limited to 'libc') diff --git a/libc/arch-arm/bionic/crtbegin_dynamic.S b/libc/arch-arm/bionic/crtbegin_dynamic.S index 624d611..e265923 100644 --- a/libc/arch-arm/bionic/crtbegin_dynamic.S +++ b/libc/arch-arm/bionic/crtbegin_dynamic.S @@ -30,35 +30,25 @@ .type _start,#function .globl _start -# This is the small startup code that is called from -# the dynamic linker to execute an executable once all -# dependent shared libraries have been loaded and -# initialized. +# this is the small startup code that is first run when +# any executable that is statically-linked with Bionic +# runs. # -# It's purpose is to call __libc_init as defined in -# bionic/libc_init_dynamic.c with appropriate +# it's purpose is to call __libc_init with appropriate # arguments, which are: # # - the address of the raw data block setup by the Linux # kernel ELF loader # -# - address of an "onexit" function (not used on any -# platform supported by Bionic) +# - address of an "onexit" function, not used on any +# platform supported by Bionic # # - address of the "main" function of the program. We # can't hard-code it in the adr pseudo instruction # so we use a tiny trampoline that will get relocated # by the dynamic linker before this code runs # -# - address of the constructors table, i.e. a table -# that points to various initialization and -# finalization sections for the program. -# -# NOTE: This code is currently placed in shared libraries -# by the build system, but will be ignored. -# -# On the other hand, the arrays defined below are -# required and will be parsed by the dynamic linker. +# - address of the constructor list # _start: mov r0, sp @@ -73,7 +63,7 @@ _start: .long __INIT_ARRAY__ .long __FINI_ARRAY__ .long __CTOR_LIST__ - + # the .ctors section contains a list of pointers to "constructor" # functions that need to be called in order during C library initialization, # just before the program is being run. This is a C++ requirement diff --git a/libc/arch-arm/bionic/crtbegin_static.S b/libc/arch-arm/bionic/crtbegin_static.S index 69d8df6..e265923 100644 --- a/libc/arch-arm/bionic/crtbegin_static.S +++ b/libc/arch-arm/bionic/crtbegin_static.S @@ -30,27 +30,25 @@ .type _start,#function .globl _start -# This is the small startup code that is first run when -# any static executable runs. A static executable is one -# that is started directly by the Linux kernel, not from -# the dynamic linker, it thus cannot depend on any shared -# library. +# this is the small startup code that is first run when +# any executable that is statically-linked with Bionic +# runs. # -# It's purpose is to call __libc_init as defined in -# bionic/libc_init_static.c with appropriate +# it's purpose is to call __libc_init with appropriate # arguments, which are: # # - the address of the raw data block setup by the Linux # kernel ELF loader # -# - address of an "onexit" function (not used on any -# platform supported by Bionic). +# - address of an "onexit" function, not used on any +# platform supported by Bionic # -# - address of the "main" function of the program. +# - address of the "main" function of the program. We +# can't hard-code it in the adr pseudo instruction +# so we use a tiny trampoline that will get relocated +# by the dynamic linker before this code runs # -# - address of the constructors table, i.e. a table -# that points to various initialization and -# finalization sections for the program. +# - address of the constructor list # _start: mov r0, sp @@ -61,18 +59,11 @@ _start: 0: b main -# The "C++ ABI for ARM" document that static C++ constructors -# shall only be called from the .init_array section. -# -# Do we really need a .ctors section on ARM platforms ? -# It looks like it will always be empty. -# - 1: .long __PREINIT_ARRAY__ .long __INIT_ARRAY__ .long __FINI_ARRAY__ .long __CTOR_LIST__ - + # the .ctors section contains a list of pointers to "constructor" # functions that need to be called in order during C library initialization, # just before the program is being run. This is a C++ requirement diff --git a/libc/arch-x86/bionic/crtbegin_dynamic.S b/libc/arch-x86/bionic/crtbegin_dynamic.S index b013641..3b47b18 100644 --- a/libc/arch-x86/bionic/crtbegin_dynamic.S +++ b/libc/arch-x86/bionic/crtbegin_dynamic.S @@ -29,35 +29,25 @@ .type _start, @function .globl _start -# This is the small startup code that is called from -# the dynamic linker to execute an executable once all -# dependent shared libraries have been loaded and -# initialized. +# this is the small startup code that is first run when +# any executable that is statically-linked with Bionic +# runs. # -# It's purpose is to call __libc_init as defined in -# bionic/libc_init_dynamic.c with appropriate +# it's purpose is to call __libc_init with appropriate # arguments, which are: # # - the address of the raw data block setup by the Linux # kernel ELF loader # -# - address of an "onexit" function (not used on any -# platform supported by Bionic) +# - address of an "onexit" function, not used on any +# platform supported by Bionic # # - address of the "main" function of the program. We # can't hard-code it in the adr pseudo instruction # so we use a tiny trampoline that will get relocated # by the dynamic linker before this code runs # -# - address of the constructors table, i.e. a table -# that points to various initialization and -# finalization sections for the program. -# -# NOTE: This code is currently placed in shared libraries -# by the build system, but will be ignored. -# -# On the other hand, the arrays defined below are -# required and will be parsed by the dynamic linker. +# - address of the constructor list # _start: mov %esp, %eax diff --git a/libc/arch-x86/bionic/crtbegin_static.S b/libc/arch-x86/bionic/crtbegin_static.S index a6c9ebf..eb4acee 100644 --- a/libc/arch-x86/bionic/crtbegin_static.S +++ b/libc/arch-x86/bionic/crtbegin_static.S @@ -29,27 +29,25 @@ .type _start, @function .globl _start -# This is the small startup code that is first run when -# any static executable runs. A static executable is one -# that is started directly by the Linux kernel, not from -# the dynamic linker, it thus cannot depend on any shared -# library. +# this is the small startup code that is first run when +# any executable that is statically-linked with Bionic +# runs. # -# It's purpose is to call __libc_init as defined in -# bionic/libc_init_static.c with appropriate +# it's purpose is to call __libc_init with appropriate # arguments, which are: # # - the address of the raw data block setup by the Linux # kernel ELF loader # -# - address of an "onexit" function (not used on any -# platform supported by Bionic). +# - address of an "onexit" function, not used on any +# platform supported by Bionic # -# - address of the "main" function of the program. +# - address of the "main" function of the program. We +# can't hard-code it in the adr pseudo instruction +# so we use a tiny trampoline that will get relocated +# by the dynamic linker before this code runs # -# - address of the constructors table, i.e. a table -# that points to various initialization and -# finalization sections for the program. +# - address of the constructor list # _start: mov %esp, %eax diff --git a/libc/bionic/libc_init_common.c b/libc/bionic/libc_init_common.c index 523afcf..de4919d 100644 --- a/libc/bionic/libc_init_common.c +++ b/libc/bionic/libc_init_common.c @@ -39,11 +39,8 @@ #include #include -/* This contains the common C library initialization code. - * To understand what happens here, you should read the - * "Initialization and Finalization" section of the file - * named bionic/linker/README.TXT - */ +extern void _init(void); +extern void _fini(void); static void call_array(void(**list)()) { @@ -53,6 +50,15 @@ static void call_array(void(**list)()) } } +static void __bionic_do_global_dtors(structors_array_t const * const p) +{ + call_array(p->fini_array); + //_fini(); +} + +extern unsigned __get_sp(void); +extern pid_t gettid(void); + char* __progname; char **environ; @@ -63,28 +69,30 @@ unsigned int __page_shift = PAGE_SHIFT; int __system_properties_init(void); -/* This function can be run under two different contexts: - * - * - for statically linked executables (i.e. those who do - * not depend on shared libraries at all), it will be - * called from the __libc_init() function defined in - * bionic/libc_init_static.c - * - * - for dynamic executables, it will be called from the - * __libc_init() function defined in bionic/libc_init_dynamic.c - * - */ void __libc_init_common(uintptr_t *elfdata, void (*onexit)(void), int (*slingshot)(int, char**, char**), structors_array_t const * const structors, void (*pre_ctor_hook)()) { + pthread_internal_t thread; + pthread_attr_t thread_attr; + void *tls_area[BIONIC_TLS_SLOTS]; int argc; char **argv, **envp, **envend; struct auxentry *auxentry; unsigned int page_size = 0, page_shift = 0; + /* The main thread's stack has empirically shown to be 84k */ + unsigned stacktop = (__get_sp() & ~(PAGE_SIZE - 1)) + PAGE_SIZE; + unsigned stacksize = 128 * 1024; //84 * 1024; + unsigned stackbottom = stacktop - stacksize; + + pthread_attr_init(&thread_attr); + pthread_attr_setstack(&thread_attr, (void*)stackbottom, stacksize); + _init_thread(&thread, gettid(), &thread_attr, (void*)stackbottom); + __init_tls(tls_area, &thread); + argc = (int) *elfdata++; argv = (char**) elfdata; envp = argv+(argc+1); @@ -98,17 +106,17 @@ void __libc_init_common(uintptr_t *elfdata, if (pre_ctor_hook) pre_ctor_hook(); - if (structors != NULL) { - // pre-init array. - call_array(structors->preinit_array); + // XXX: we should execute the .fini_array upon exit - // for compatibility with non-eabi binary, call the .ctors section - // this is only useful for static non-ARM (e.g. x86) executables. - call_array(structors->ctors_array); + // pre-init array. + // XXX: I'm not sure what's the different with the init array. + call_array(structors->preinit_array); - // call static constructors - call_array(structors->init_array); - } + // for compatibility with non-eabi binary, call the .ctors section + call_array(structors->ctors_array); + + // call static constructors + call_array(structors->init_array); exit(slingshot(argc, argv, envp)); } diff --git a/libc/bionic/libc_init_dynamic.c b/libc/bionic/libc_init_dynamic.c index e1ff13d..8cf24b4 100644 --- a/libc/bionic/libc_init_dynamic.c +++ b/libc/bionic/libc_init_dynamic.c @@ -25,29 +25,18 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - /* * libc_init_static.c * - * This function is called for dynamic executables after the dynamic - * linker has loaded and initialized all dependent shared libraries. - * - * It takes the raw data block set up by the ELF loader - * in the kernel and parses it. + * This function takes the raw data block set up by the ELF loader + * in the kernel and parses it. It is invoked by crt0.S which makes + * any necessary adjustments and passes calls this function using + * the standard C calling convention. * * The arguments are: - * elfdata -- The ELF loader data block; usually from the stack. - * Basically a pointer to argc. - * - * onexit -- Function to call on exit, can be NULL. - * - * slingshot -- Address of the program's main function - * - * structors -- Table of constructor functions arrays that must - * be called before the slingshot. - * - * It is called from the assembly fragment found in - * arch-$ARCH/bionic/crtbegin_dynamic.S + * uintptr_t *elfdata -- The ELF loader data block; usually from the stack. + * Basically a pointer to argc. + * void (*onexit)(void) -- Function to install into onexit */ /* @@ -73,18 +62,5 @@ __noreturn void __libc_init(uintptr_t *elfdata, int (*slingshot)(int, char**, char**), structors_array_t const * const structors) { - /* NOTE: At this point, the dynamic linker has *already* called - * all initializers properly, so we ignore 'structors' to - * avoid calling them twice. - */ - - /* NOTE2: Is it worthwhile to use malloc_debug_init() in the case of - * of the non-debug shared C library ? - * - * The implementation in bionic/malloc_leak.c contains a lot - * of code which will turn to be unused, and we add a dispatch - * overhead to malloc() et al. that proved to be significant - * in the past (e.g. making boot sequence 5% slower) - */ - __libc_init_common(elfdata, onexit, slingshot, NULL, malloc_debug_init); + __libc_init_common(elfdata, onexit, slingshot, structors, malloc_debug_init); } diff --git a/libc/bionic/libc_init_static.c b/libc/bionic/libc_init_static.c index d7af640..ec463f7 100644 --- a/libc/bionic/libc_init_static.c +++ b/libc/bionic/libc_init_static.c @@ -25,30 +25,18 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - /* * libc_init_static.c * - * This function is called for static executables, i.e. those that - * dont depend on shared libraries and are directly started by the - * Linux kernel. - * - * It takes the raw data block set up by the ELF loader - * in the kernel and parses it. + * This function takes the raw data block set up by the ELF loader + * in the kernel and parses it. It is invoked by crt0.S which makes + * any necessary adjustments and passes calls this function using + * the standard C calling convention. * * The arguments are: - * elfdata -- The ELF loader data block; usually from the stack. - * Basically a pointer to argc. - * - * onexit -- Function to call on exit, can be NULL. - * - * slingshot -- Address of the program's main function - * - * structors -- Table of constructor functions arrays that must - * be called before the slingshot. - * - * It is called from the assembly fragment found in - * arch-$ARCH/bionic/crtbegin_static.S + * uintptr_t *elfdata -- The ELF loader data block; usually from the stack. + * Basically a pointer to argc. + * void (*onexit)(void) -- Function to install into onexit */ /* @@ -63,19 +51,18 @@ #include #include #include -#include "bionic_preinit.h" +#include "pthread_internal.h" +#include "atexit.h" #include "libc_init_common.h" +#include +#include + __noreturn void __libc_init(uintptr_t *elfdata, void (*onexit)(void), int (*slingshot)(int, char**, char**), structors_array_t const * const structors) { - pthread_internal_t thread; - void *tls_area[BIONIC_TLS_SLOTS]; - - __libc_preinit( &thread, tls_area ); - /* * To enable malloc checks for statically linked programs, add * "WITH_MALLOC_CHECK_LIBC_A := true" in device/buildspec.mk diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h new file mode 100644 index 0000000..eb4e80c --- /dev/null +++ b/libc/bionic/pthread_internal.h @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef _PTHREAD_INTERNAL_H_ +#define _PTHREAD_INTERNAL_H_ + +#include + +__BEGIN_DECLS + +typedef struct pthread_internal_t +{ + struct pthread_internal_t* next; + struct pthread_internal_t** pref; + pthread_attr_t attr; + pid_t kernel_id; + pthread_cond_t join_cond; + int join_count; + void* return_value; + int intern; + __pthread_cleanup_t* cleanup_stack; + void** tls; /* thread-local storage area */ +} pthread_internal_t; + +extern void _init_thread(pthread_internal_t * thread, pid_t kernel_id, pthread_attr_t * attr, void * stack_base); + +/* needed by posix-timers.c */ + +static __inline__ void timespec_add( struct timespec* a, const struct timespec* b ) +{ + a->tv_sec += b->tv_sec; + a->tv_nsec += b->tv_nsec; + if (a->tv_nsec >= 1000000000) { + a->tv_nsec -= 1000000000; + a->tv_sec += 1; + } +} + +static __inline__ void timespec_sub( struct timespec* a, const struct timespec* b ) +{ + a->tv_sec -= b->tv_sec; + a->tv_nsec -= b->tv_nsec; + if (a->tv_nsec < 0) { + a->tv_nsec += 1000000000; + a->tv_sec -= 1; + } +} + +static __inline__ void timespec_zero( struct timespec* a ) +{ + a->tv_sec = a->tv_nsec = 0; +} + +static __inline__ int timespec_is_zero( const struct timespec* a ) +{ + return (a->tv_sec == 0 && a->tv_nsec == 0); +} + +static __inline__ int timespec_cmp( const struct timespec* a, const struct timespec* b ) +{ + if (a->tv_sec < b->tv_sec) return -1; + if (a->tv_sec > b->tv_sec) return +1; + if (a->tv_nsec < b->tv_nsec) return -1; + if (a->tv_nsec > b->tv_nsec) return +1; + return 0; +} + +static __inline__ int timespec_cmp0( const struct timespec* a ) +{ + if (a->tv_sec < 0) return -1; + if (a->tv_sec > 0) return +1; + if (a->tv_nsec < 0) return -1; + if (a->tv_nsec > 0) return +1; + return 0; +} + +extern int __pthread_cond_timedwait(pthread_cond_t*, + pthread_mutex_t*, + const struct timespec*, + clockid_t); + +extern int __pthread_cond_timedwait_relative(pthread_cond_t*, + pthread_mutex_t*, + const struct timespec*); + +/* needed by fork.c */ +extern void __timer_table_start_stop(int stop); + +__END_DECLS + +#endif /* _PTHREAD_INTERNAL_H_ */ diff --git a/libc/private/bionic_preinit.h b/libc/private/bionic_preinit.h deleted file mode 100644 index b74a8b4..0000000 --- a/libc/private/bionic_preinit.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _BIONIC_PREINIT_H -#define _BIONIC_PREINIT_H - -#include "pthread_internal.h" -#include "bionic_tls.h" -#include - -/* this function is used to perform a minimal initialization of the - * the C library. This must be performed before any other call to - * other functions, in either the dynamic linker's startup code - * or libc_init_static.c - * - * 'main_thread' and 'tls_area' must be persistent variables, - * which means they must be either global, or allocated in the - * main thread's stack frame and never, ever, freed before - * program exit. - * - * VERY IMPORTANT NOTE: - * - * THIS IMPLEMENTATION SHOULD NOT USE GLOBAL VARIABLES. - * - * The reason is the dynamic linker's tricky usage of C library - * functions and later renaming of their symbols. See the - * "C Library Usage Restriction" section in bionic/linker/README.TXT - * for details. - */ - -extern unsigned __get_sp(void); -extern pid_t gettid(void); - -static __inline__ void -__libc_preinit( pthread_internal_t* main_thread, - void* tls_area[BIONIC_TLS_SLOTS] ) -{ - pthread_attr_t thread_attr; - - /* Setup the main thread's information */ - unsigned stacktop = (__get_sp() & ~(PAGE_SIZE - 1)) + PAGE_SIZE; - unsigned stacksize = 128 * 1024; - unsigned stackbottom = stacktop - stacksize; - - pthread_attr_init(&thread_attr); - pthread_attr_setstack(&thread_attr, (void*)stackbottom, stacksize); - _init_thread(main_thread, gettid(), &thread_attr, (void*)stackbottom); - __init_tls(tls_area, main_thread); -} - -#endif /* _BIONIC_INIT_H */ diff --git a/libc/private/pthread_internal.h b/libc/private/pthread_internal.h deleted file mode 100644 index eb4e80c..0000000 --- a/libc/private/pthread_internal.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#ifndef _PTHREAD_INTERNAL_H_ -#define _PTHREAD_INTERNAL_H_ - -#include - -__BEGIN_DECLS - -typedef struct pthread_internal_t -{ - struct pthread_internal_t* next; - struct pthread_internal_t** pref; - pthread_attr_t attr; - pid_t kernel_id; - pthread_cond_t join_cond; - int join_count; - void* return_value; - int intern; - __pthread_cleanup_t* cleanup_stack; - void** tls; /* thread-local storage area */ -} pthread_internal_t; - -extern void _init_thread(pthread_internal_t * thread, pid_t kernel_id, pthread_attr_t * attr, void * stack_base); - -/* needed by posix-timers.c */ - -static __inline__ void timespec_add( struct timespec* a, const struct timespec* b ) -{ - a->tv_sec += b->tv_sec; - a->tv_nsec += b->tv_nsec; - if (a->tv_nsec >= 1000000000) { - a->tv_nsec -= 1000000000; - a->tv_sec += 1; - } -} - -static __inline__ void timespec_sub( struct timespec* a, const struct timespec* b ) -{ - a->tv_sec -= b->tv_sec; - a->tv_nsec -= b->tv_nsec; - if (a->tv_nsec < 0) { - a->tv_nsec += 1000000000; - a->tv_sec -= 1; - } -} - -static __inline__ void timespec_zero( struct timespec* a ) -{ - a->tv_sec = a->tv_nsec = 0; -} - -static __inline__ int timespec_is_zero( const struct timespec* a ) -{ - return (a->tv_sec == 0 && a->tv_nsec == 0); -} - -static __inline__ int timespec_cmp( const struct timespec* a, const struct timespec* b ) -{ - if (a->tv_sec < b->tv_sec) return -1; - if (a->tv_sec > b->tv_sec) return +1; - if (a->tv_nsec < b->tv_nsec) return -1; - if (a->tv_nsec > b->tv_nsec) return +1; - return 0; -} - -static __inline__ int timespec_cmp0( const struct timespec* a ) -{ - if (a->tv_sec < 0) return -1; - if (a->tv_sec > 0) return +1; - if (a->tv_nsec < 0) return -1; - if (a->tv_nsec > 0) return +1; - return 0; -} - -extern int __pthread_cond_timedwait(pthread_cond_t*, - pthread_mutex_t*, - const struct timespec*, - clockid_t); - -extern int __pthread_cond_timedwait_relative(pthread_cond_t*, - pthread_mutex_t*, - const struct timespec*); - -/* needed by fork.c */ -extern void __timer_table_start_stop(int stop); - -__END_DECLS - -#endif /* _PTHREAD_INTERNAL_H_ */ -- cgit v1.1 From bf8709f54b1eabbd4e9bb81e91b9385a9863f505 Mon Sep 17 00:00:00 2001 From: Iliyan Malchev Date: Thu, 4 Jun 2009 11:55:53 -0700 Subject: bionic: update msm_camera.h header Signed-off-by: Iliyan Malchev --- libc/kernel/common/media/msm_camera.h | 76 +++++++++++++++++------------------ 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'libc') diff --git a/libc/kernel/common/media/msm_camera.h b/libc/kernel/common/media/msm_camera.h index 750232e..520976e 100644 --- a/libc/kernel/common/media/msm_camera.h +++ b/libc/kernel/common/media/msm_camera.h @@ -18,47 +18,47 @@ #define MSM_CAM_IOCTL_MAGIC 'm' -#define MSM_CAM_IOCTL_GET_SENSOR_INFO _IOR(MSM_CAM_IOCTL_MAGIC, 1, struct msm_camsensor_info_t *) +#define MSM_CAM_IOCTL_GET_SENSOR_INFO _IOR(MSM_CAM_IOCTL_MAGIC, 1, struct msm_camsensor_info *) -#define MSM_CAM_IOCTL_REGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 2, struct msm_pmem_info_t *) +#define MSM_CAM_IOCTL_REGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 2, struct msm_pmem_info *) #define MSM_CAM_IOCTL_UNREGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 3, unsigned) -#define MSM_CAM_IOCTL_CTRL_COMMAND _IOW(MSM_CAM_IOCTL_MAGIC, 4, struct msm_ctrl_cmd_t *) +#define MSM_CAM_IOCTL_CTRL_COMMAND _IOW(MSM_CAM_IOCTL_MAGIC, 4, struct msm_ctrl_cmd *) -#define MSM_CAM_IOCTL_CONFIG_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 5, struct msm_camera_vfe_cfg_cmd_t *) +#define MSM_CAM_IOCTL_CONFIG_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 5, struct msm_camera_vfe_cfg_cmd *) -#define MSM_CAM_IOCTL_GET_STATS _IOR(MSM_CAM_IOCTL_MAGIC, 6, struct msm_camera_stats_event_ctrl_t *) +#define MSM_CAM_IOCTL_GET_STATS _IOR(MSM_CAM_IOCTL_MAGIC, 6, struct msm_camera_stats_event_ctrl *) -#define MSM_CAM_IOCTL_GETFRAME _IOR(MSM_CAM_IOCTL_MAGIC, 7, struct msm_camera_get_frame_t *) +#define MSM_CAM_IOCTL_GETFRAME _IOR(MSM_CAM_IOCTL_MAGIC, 7, struct msm_camera_get_frame *) -#define MSM_CAM_IOCTL_ENABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 8, struct camera_enable_cmd_t *) +#define MSM_CAM_IOCTL_ENABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 8, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_CTRL_CMD_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 9, struct camera_cmd_t *) +#define MSM_CAM_IOCTL_CTRL_CMD_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 9, struct camera_cmd *) -#define MSM_CAM_IOCTL_CONFIG_CMD _IOW(MSM_CAM_IOCTL_MAGIC, 10, struct camera_cmd_t *) +#define MSM_CAM_IOCTL_CONFIG_CMD _IOW(MSM_CAM_IOCTL_MAGIC, 10, struct camera_cmd *) -#define MSM_CAM_IOCTL_DISABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 11, struct camera_enable_cmd_t *) +#define MSM_CAM_IOCTL_DISABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 11, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_PAD_REG_RESET2 _IOW(MSM_CAM_IOCTL_MAGIC, 12, struct camera_enable_cmd_t *) +#define MSM_CAM_IOCTL_PAD_REG_RESET2 _IOW(MSM_CAM_IOCTL_MAGIC, 12, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_VFE_APPS_RESET _IOW(MSM_CAM_IOCTL_MAGIC, 13, struct camera_enable_cmd_t *) +#define MSM_CAM_IOCTL_VFE_APPS_RESET _IOW(MSM_CAM_IOCTL_MAGIC, 13, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 14, struct camera_enable_cmd_t *) +#define MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 14, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_RELEASE_STATS_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 15, struct msm_stats_buf_t *) +#define MSM_CAM_IOCTL_RELEASE_STATS_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 15, struct msm_stats_buf *) -#define MSM_CAM_IOCTL_AXI_CONFIG _IOW(MSM_CAM_IOCTL_MAGIC, 16, struct msm_camera_vfe_cfg_cmd_t *) +#define MSM_CAM_IOCTL_AXI_CONFIG _IOW(MSM_CAM_IOCTL_MAGIC, 16, struct msm_camera_vfe_cfg_cmd *) -#define MSM_CAM_IOCTL_GET_PICTURE _IOW(MSM_CAM_IOCTL_MAGIC, 17, struct msm_camera_ctrl_cmd_t *) +#define MSM_CAM_IOCTL_GET_PICTURE _IOW(MSM_CAM_IOCTL_MAGIC, 17, struct msm_camera_ctrl_cmd *) -#define MSM_CAM_IOCTL_SET_CROP _IOW(MSM_CAM_IOCTL_MAGIC, 18, struct crop_info_t *) +#define MSM_CAM_IOCTL_SET_CROP _IOW(MSM_CAM_IOCTL_MAGIC, 18, struct crop_info *) #define MSM_CAM_IOCTL_PICT_PP _IOW(MSM_CAM_IOCTL_MAGIC, 19, uint8_t *) -#define MSM_CAM_IOCTL_PICT_PP_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 20, struct msm_snapshot_pp_status_t *) +#define MSM_CAM_IOCTL_PICT_PP_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 20, struct msm_snapshot_pp_status *) -#define MSM_CAM_IOCTL_SENSOR_IO_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 21, struct sensor_cfg_data_t *) +#define MSM_CAM_IOCTL_SENSOR_IO_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 21, struct sensor_cfg_data *) #define MSM_CAMERA_LED_OFF 0 #define MSM_CAMERA_LED_LOW 1 @@ -68,7 +68,7 @@ #define MSM_CAM_IOCTL_UNBLOCK_POLL_FRAME _IO(MSM_CAM_IOCTL_MAGIC, 23) -#define MSM_CAM_IOCTL_CTRL_COMMAND_2 _IOW(MSM_CAM_IOCTL_MAGIC, 24, struct msm_ctrl_cmd_t *) +#define MSM_CAM_IOCTL_CTRL_COMMAND_2 _IOW(MSM_CAM_IOCTL_MAGIC, 24, struct msm_ctrl_cmd *) #define MAX_SENSOR_NUM 3 #define MAX_SENSOR_NAME 32 @@ -76,7 +76,7 @@ #define MSM_CAM_CTRL_CMD_DONE 0 #define MSM_CAM_SENSOR_VFE_CMD 1 -struct msm_ctrl_cmd_t { +struct msm_ctrl_cmd { uint16_t type; uint16_t length; void *value; @@ -85,7 +85,7 @@ struct msm_ctrl_cmd_t { int resp_fd; }; -struct msm_vfe_evt_msg_t { +struct msm_vfe_evt_msg { unsigned short type; unsigned short msg_id; unsigned int len; @@ -101,12 +101,12 @@ struct msm_stats_event_ctrl { int resptype; int timeout_ms; - struct msm_ctrl_cmd_t ctrl_cmd; + struct msm_ctrl_cmd ctrl_cmd; - struct msm_vfe_evt_msg_t stats_event; + struct msm_vfe_evt_msg stats_event; }; -struct msm_camera_cfg_cmd_t { +struct msm_camera_cfg_cmd { uint16_t cfg_type; @@ -136,14 +136,14 @@ struct msm_camera_cfg_cmd_t { #define CMD_STATS_AF_BUF_RELEASE 17 #define UPDATE_STATS_INVALID 18 -struct msm_vfe_cfg_cmd_t { +struct msm_vfe_cfg_cmd { int cmd_type; uint16_t length; void *value; }; #define MAX_CAMERA_ENABLE_NAME_LEN 32 -struct camera_enable_cmd_t { +struct camera_enable_cmd { char name[MAX_CAMERA_ENABLE_NAME_LEN]; }; @@ -164,7 +164,7 @@ struct camera_enable_cmd_t { #define FRAME_RAW_SNAPSHOT 4 #define FRAME_MAX 5 -struct msm_pmem_info_t { +struct msm_pmem_info { int type; int fd; void *vaddr; @@ -173,7 +173,7 @@ struct msm_pmem_info_t { uint8_t active; }; -struct outputCfg_t { +struct outputCfg { uint32_t height; uint32_t width; @@ -193,7 +193,7 @@ struct outputCfg_t { #define MSM_FRAME_PREV_2 1 #define MSM_FRAME_ENC 2 -struct msm_frame_t { +struct msm_frame { int path; unsigned long buffer; uint32_t y_off; @@ -208,7 +208,7 @@ struct msm_frame_t { #define STAT_AF 1 #define STAT_MAX 2 -struct msm_stats_buf_t { +struct msm_stats_buf { int type; unsigned long buffer; int fd; @@ -224,19 +224,19 @@ struct msm_stats_buf_t { #define MSM_V4L2_QUERY 7 #define MSM_V4L2_MAX 8 -struct crop_info_t { +struct crop_info { void *info; int len; }; -struct msm_postproc_t { +struct msm_postproc { int ftnum; - struct msm_frame_t fthumnail; + struct msm_frame fthumnail; int fmnum; - struct msm_frame_t fmain; + struct msm_frame fmain; }; -struct msm_snapshot_pp_status_t { +struct msm_snapshot_pp_status { void *status; }; @@ -316,7 +316,7 @@ struct fps_cfg { uint32_t pict_fps_div; }; -struct sensor_cfg_data_t { +struct sensor_cfg_data { int cfgtype; int mode; int rs; @@ -346,7 +346,7 @@ struct sensor_cfg_data_t { #define GET_SNAPSHOT_FPS 5 #define GET_SNAPSHOT_MAX_EP_LINE_CNT 6 -struct msm_camsensor_info_t { +struct msm_camsensor_info { char name[MAX_SENSOR_NAME]; uint8_t flash_enabled; }; -- cgit v1.1 From 3ddc15e10a6f5690e53e729c0da2c42f0eb944d1 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Fri, 12 Jun 2009 14:21:49 +0200 Subject: Add new clean header for PPP on PPTP (VPN) --- libc/kernel/common/linux/if_pppopns.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 libc/kernel/common/linux/if_pppopns.h (limited to 'libc') diff --git a/libc/kernel/common/linux/if_pppopns.h b/libc/kernel/common/linux/if_pppopns.h new file mode 100644 index 0000000..ac75210 --- /dev/null +++ b/libc/kernel/common/linux/if_pppopns.h @@ -0,0 +1,28 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + **************************************************************************** + ****************************************************************************/ +#ifndef __LINUX_IF_PPPOPNS_H +#define __LINUX_IF_PPPOPNS_H + +#include +#include + +#define PX_PROTO_OPNS 3 + +struct sockaddr_pppopns { + sa_family_t sa_family; + unsigned int sa_protocol; + int tcp_socket; + __u16 local; + __u16 remote; +} __attribute__((packed)); + +#endif -- cgit v1.1 From 9cfccefa055554c7e951741c01373a52a82d3fd6 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Fri, 12 Jun 2009 14:37:15 +0200 Subject: Update cleaned-up kernel headers --- libc/kernel/common/linux/msm_adsp.h | 22 ++++++++-------- libc/kernel/common/media/msm_camera.h | 48 +++++++++++++++++------------------ 2 files changed, 35 insertions(+), 35 deletions(-) (limited to 'libc') diff --git a/libc/kernel/common/linux/msm_adsp.h b/libc/kernel/common/linux/msm_adsp.h index f6ab29d..b138a5d 100644 --- a/libc/kernel/common/linux/msm_adsp.h +++ b/libc/kernel/common/linux/msm_adsp.h @@ -32,32 +32,32 @@ struct adsp_event_t { uint8_t *data; }; -#define ADSP_IOCTL_ENABLE _IOR(ADSP_IOCTL_MAGIC, 1, unsigned) +#define ADSP_IOCTL_ENABLE _IOR(ADSP_IOCTL_MAGIC, 1, unsigned) -#define ADSP_IOCTL_DISABLE _IOR(ADSP_IOCTL_MAGIC, 2, unsigned) +#define ADSP_IOCTL_DISABLE _IOR(ADSP_IOCTL_MAGIC, 2, unsigned) -#define ADSP_IOCTL_DISABLE_ACK _IOR(ADSP_IOCTL_MAGIC, 3, unsigned) +#define ADSP_IOCTL_DISABLE_ACK _IOR(ADSP_IOCTL_MAGIC, 3, unsigned) -#define ADSP_IOCTL_WRITE_COMMAND _IOR(ADSP_IOCTL_MAGIC, 4, struct adsp_command_t *) +#define ADSP_IOCTL_WRITE_COMMAND _IOR(ADSP_IOCTL_MAGIC, 4, struct adsp_command_t *) -#define ADSP_IOCTL_GET_EVENT _IOWR(ADSP_IOCTL_MAGIC, 5, struct adsp_event_data_t *) +#define ADSP_IOCTL_GET_EVENT _IOWR(ADSP_IOCTL_MAGIC, 5, struct adsp_event_data_t *) -#define ADSP_IOCTL_SET_CLKRATE _IOR(ADSP_IOCTL_MAGIC, 6, unsigned) +#define ADSP_IOCTL_SET_CLKRATE _IOR(ADSP_IOCTL_MAGIC, 6, unsigned) -#define ADSP_IOCTL_DISABLE_EVENT_RSP _IOR(ADSP_IOCTL_MAGIC, 10, unsigned) +#define ADSP_IOCTL_DISABLE_EVENT_RSP _IOR(ADSP_IOCTL_MAGIC, 10, unsigned) struct adsp_pmem_info { int fd; void *vaddr; }; -#define ADSP_IOCTL_REGISTER_PMEM _IOW(ADSP_IOCTL_MAGIC, 13, unsigned) +#define ADSP_IOCTL_REGISTER_PMEM _IOW(ADSP_IOCTL_MAGIC, 13, unsigned) -#define ADSP_IOCTL_UNREGISTER_PMEM _IOW(ADSP_IOCTL_MAGIC, 14, unsigned) +#define ADSP_IOCTL_UNREGISTER_PMEM _IOW(ADSP_IOCTL_MAGIC, 14, unsigned) -#define ADSP_IOCTL_ABORT_EVENT_READ _IOW(ADSP_IOCTL_MAGIC, 15, unsigned) +#define ADSP_IOCTL_ABORT_EVENT_READ _IOW(ADSP_IOCTL_MAGIC, 15, unsigned) -#define ADSP_IOCTL_LINK_TASK _IOW(ADSP_IOCTL_MAGIC, 16, unsigned) +#define ADSP_IOCTL_LINK_TASK _IOW(ADSP_IOCTL_MAGIC, 16, unsigned) #endif diff --git a/libc/kernel/common/media/msm_camera.h b/libc/kernel/common/media/msm_camera.h index 520976e..ac235f4 100644 --- a/libc/kernel/common/media/msm_camera.h +++ b/libc/kernel/common/media/msm_camera.h @@ -18,57 +18,57 @@ #define MSM_CAM_IOCTL_MAGIC 'm' -#define MSM_CAM_IOCTL_GET_SENSOR_INFO _IOR(MSM_CAM_IOCTL_MAGIC, 1, struct msm_camsensor_info *) +#define MSM_CAM_IOCTL_GET_SENSOR_INFO _IOR(MSM_CAM_IOCTL_MAGIC, 1, struct msm_camsensor_info *) -#define MSM_CAM_IOCTL_REGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 2, struct msm_pmem_info *) +#define MSM_CAM_IOCTL_REGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 2, struct msm_pmem_info *) -#define MSM_CAM_IOCTL_UNREGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 3, unsigned) +#define MSM_CAM_IOCTL_UNREGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 3, unsigned) -#define MSM_CAM_IOCTL_CTRL_COMMAND _IOW(MSM_CAM_IOCTL_MAGIC, 4, struct msm_ctrl_cmd *) +#define MSM_CAM_IOCTL_CTRL_COMMAND _IOW(MSM_CAM_IOCTL_MAGIC, 4, struct msm_ctrl_cmd *) -#define MSM_CAM_IOCTL_CONFIG_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 5, struct msm_camera_vfe_cfg_cmd *) +#define MSM_CAM_IOCTL_CONFIG_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 5, struct msm_camera_vfe_cfg_cmd *) -#define MSM_CAM_IOCTL_GET_STATS _IOR(MSM_CAM_IOCTL_MAGIC, 6, struct msm_camera_stats_event_ctrl *) +#define MSM_CAM_IOCTL_GET_STATS _IOR(MSM_CAM_IOCTL_MAGIC, 6, struct msm_camera_stats_event_ctrl *) -#define MSM_CAM_IOCTL_GETFRAME _IOR(MSM_CAM_IOCTL_MAGIC, 7, struct msm_camera_get_frame *) +#define MSM_CAM_IOCTL_GETFRAME _IOR(MSM_CAM_IOCTL_MAGIC, 7, struct msm_camera_get_frame *) -#define MSM_CAM_IOCTL_ENABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 8, struct camera_enable_cmd *) +#define MSM_CAM_IOCTL_ENABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 8, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_CTRL_CMD_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 9, struct camera_cmd *) +#define MSM_CAM_IOCTL_CTRL_CMD_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 9, struct camera_cmd *) -#define MSM_CAM_IOCTL_CONFIG_CMD _IOW(MSM_CAM_IOCTL_MAGIC, 10, struct camera_cmd *) +#define MSM_CAM_IOCTL_CONFIG_CMD _IOW(MSM_CAM_IOCTL_MAGIC, 10, struct camera_cmd *) -#define MSM_CAM_IOCTL_DISABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 11, struct camera_enable_cmd *) +#define MSM_CAM_IOCTL_DISABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 11, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_PAD_REG_RESET2 _IOW(MSM_CAM_IOCTL_MAGIC, 12, struct camera_enable_cmd *) +#define MSM_CAM_IOCTL_PAD_REG_RESET2 _IOW(MSM_CAM_IOCTL_MAGIC, 12, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_VFE_APPS_RESET _IOW(MSM_CAM_IOCTL_MAGIC, 13, struct camera_enable_cmd *) +#define MSM_CAM_IOCTL_VFE_APPS_RESET _IOW(MSM_CAM_IOCTL_MAGIC, 13, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 14, struct camera_enable_cmd *) +#define MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 14, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_RELEASE_STATS_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 15, struct msm_stats_buf *) +#define MSM_CAM_IOCTL_RELEASE_STATS_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 15, struct msm_stats_buf *) -#define MSM_CAM_IOCTL_AXI_CONFIG _IOW(MSM_CAM_IOCTL_MAGIC, 16, struct msm_camera_vfe_cfg_cmd *) +#define MSM_CAM_IOCTL_AXI_CONFIG _IOW(MSM_CAM_IOCTL_MAGIC, 16, struct msm_camera_vfe_cfg_cmd *) -#define MSM_CAM_IOCTL_GET_PICTURE _IOW(MSM_CAM_IOCTL_MAGIC, 17, struct msm_camera_ctrl_cmd *) +#define MSM_CAM_IOCTL_GET_PICTURE _IOW(MSM_CAM_IOCTL_MAGIC, 17, struct msm_camera_ctrl_cmd *) -#define MSM_CAM_IOCTL_SET_CROP _IOW(MSM_CAM_IOCTL_MAGIC, 18, struct crop_info *) +#define MSM_CAM_IOCTL_SET_CROP _IOW(MSM_CAM_IOCTL_MAGIC, 18, struct crop_info *) -#define MSM_CAM_IOCTL_PICT_PP _IOW(MSM_CAM_IOCTL_MAGIC, 19, uint8_t *) +#define MSM_CAM_IOCTL_PICT_PP _IOW(MSM_CAM_IOCTL_MAGIC, 19, uint8_t *) -#define MSM_CAM_IOCTL_PICT_PP_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 20, struct msm_snapshot_pp_status *) +#define MSM_CAM_IOCTL_PICT_PP_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 20, struct msm_snapshot_pp_status *) -#define MSM_CAM_IOCTL_SENSOR_IO_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 21, struct sensor_cfg_data *) +#define MSM_CAM_IOCTL_SENSOR_IO_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 21, struct sensor_cfg_data *) #define MSM_CAMERA_LED_OFF 0 #define MSM_CAMERA_LED_LOW 1 #define MSM_CAMERA_LED_HIGH 2 -#define MSM_CAM_IOCTL_FLASH_LED_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 22, unsigned *) +#define MSM_CAM_IOCTL_FLASH_LED_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 22, unsigned *) -#define MSM_CAM_IOCTL_UNBLOCK_POLL_FRAME _IO(MSM_CAM_IOCTL_MAGIC, 23) +#define MSM_CAM_IOCTL_UNBLOCK_POLL_FRAME _IO(MSM_CAM_IOCTL_MAGIC, 23) -#define MSM_CAM_IOCTL_CTRL_COMMAND_2 _IOW(MSM_CAM_IOCTL_MAGIC, 24, struct msm_ctrl_cmd *) +#define MSM_CAM_IOCTL_CTRL_COMMAND_2 _IOW(MSM_CAM_IOCTL_MAGIC, 24, struct msm_ctrl_cmd *) #define MAX_SENSOR_NUM 3 #define MAX_SENSOR_NAME 32 -- cgit v1.1 From 09baf4e881c78e67c7849aa81432ceb34e72e913 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Mon, 22 Jun 2009 12:16:06 +0200 Subject: Add Glibc-compatible macro aliases for the nanosecond time accessors in stat structure --- libc/include/sys/stat.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libc') diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index 23ab5ae..091ee6d 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -71,6 +71,13 @@ struct stat { unsigned long long st_ino; }; +/* For compatibility with GLibc, we provide macro aliases + * for the non-Posix nano-seconds accessors. + */ +#define st_atimensec st_atime_nsec +#define st_mtimensec st_mtime_nsec +#define st_ctimensec st_ctime_nsec + extern int chmod(const char *, mode_t); extern int fchmod(int, mode_t); extern int mkdir(const char *, mode_t); -- cgit v1.1 From 0711600b05098d252686a0d60d621419b59256aa Mon Sep 17 00:00:00 2001 From: Iliyan Malchev Date: Tue, 23 Jun 2009 20:08:10 -0700 Subject: update clean msm_camera.h Signed-off-by: Iliyan Malchev --- libc/kernel/common/media/msm_camera.h | 50 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'libc') diff --git a/libc/kernel/common/media/msm_camera.h b/libc/kernel/common/media/msm_camera.h index ac235f4..6596d6b 100644 --- a/libc/kernel/common/media/msm_camera.h +++ b/libc/kernel/common/media/msm_camera.h @@ -18,57 +18,57 @@ #define MSM_CAM_IOCTL_MAGIC 'm' -#define MSM_CAM_IOCTL_GET_SENSOR_INFO _IOR(MSM_CAM_IOCTL_MAGIC, 1, struct msm_camsensor_info *) +#define MSM_CAM_IOCTL_GET_SENSOR_INFO _IOR(MSM_CAM_IOCTL_MAGIC, 1, struct msm_camsensor_info *) -#define MSM_CAM_IOCTL_REGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 2, struct msm_pmem_info *) +#define MSM_CAM_IOCTL_REGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 2, struct msm_pmem_info *) -#define MSM_CAM_IOCTL_UNREGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 3, unsigned) +#define MSM_CAM_IOCTL_UNREGISTER_PMEM _IOW(MSM_CAM_IOCTL_MAGIC, 3, unsigned) -#define MSM_CAM_IOCTL_CTRL_COMMAND _IOW(MSM_CAM_IOCTL_MAGIC, 4, struct msm_ctrl_cmd *) +#define MSM_CAM_IOCTL_CTRL_COMMAND _IOW(MSM_CAM_IOCTL_MAGIC, 4, struct msm_ctrl_cmd *) -#define MSM_CAM_IOCTL_CONFIG_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 5, struct msm_camera_vfe_cfg_cmd *) +#define MSM_CAM_IOCTL_CONFIG_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 5, struct msm_camera_vfe_cfg_cmd *) -#define MSM_CAM_IOCTL_GET_STATS _IOR(MSM_CAM_IOCTL_MAGIC, 6, struct msm_camera_stats_event_ctrl *) +#define MSM_CAM_IOCTL_GET_STATS _IOR(MSM_CAM_IOCTL_MAGIC, 6, struct msm_camera_stats_event_ctrl *) -#define MSM_CAM_IOCTL_GETFRAME _IOR(MSM_CAM_IOCTL_MAGIC, 7, struct msm_camera_get_frame *) +#define MSM_CAM_IOCTL_GETFRAME _IOR(MSM_CAM_IOCTL_MAGIC, 7, struct msm_camera_get_frame *) -#define MSM_CAM_IOCTL_ENABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 8, struct camera_enable_cmd *) +#define MSM_CAM_IOCTL_ENABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 8, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_CTRL_CMD_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 9, struct camera_cmd *) +#define MSM_CAM_IOCTL_CTRL_CMD_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 9, struct camera_cmd *) -#define MSM_CAM_IOCTL_CONFIG_CMD _IOW(MSM_CAM_IOCTL_MAGIC, 10, struct camera_cmd *) +#define MSM_CAM_IOCTL_CONFIG_CMD _IOW(MSM_CAM_IOCTL_MAGIC, 10, struct camera_cmd *) -#define MSM_CAM_IOCTL_DISABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 11, struct camera_enable_cmd *) +#define MSM_CAM_IOCTL_DISABLE_VFE _IOW(MSM_CAM_IOCTL_MAGIC, 11, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_PAD_REG_RESET2 _IOW(MSM_CAM_IOCTL_MAGIC, 12, struct camera_enable_cmd *) +#define MSM_CAM_IOCTL_PAD_REG_RESET2 _IOW(MSM_CAM_IOCTL_MAGIC, 12, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_VFE_APPS_RESET _IOW(MSM_CAM_IOCTL_MAGIC, 13, struct camera_enable_cmd *) +#define MSM_CAM_IOCTL_VFE_APPS_RESET _IOW(MSM_CAM_IOCTL_MAGIC, 13, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 14, struct camera_enable_cmd *) +#define MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 14, struct camera_enable_cmd *) -#define MSM_CAM_IOCTL_RELEASE_STATS_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 15, struct msm_stats_buf *) +#define MSM_CAM_IOCTL_RELEASE_STATS_BUFFER _IOW(MSM_CAM_IOCTL_MAGIC, 15, struct msm_stats_buf *) -#define MSM_CAM_IOCTL_AXI_CONFIG _IOW(MSM_CAM_IOCTL_MAGIC, 16, struct msm_camera_vfe_cfg_cmd *) +#define MSM_CAM_IOCTL_AXI_CONFIG _IOW(MSM_CAM_IOCTL_MAGIC, 16, struct msm_camera_vfe_cfg_cmd *) -#define MSM_CAM_IOCTL_GET_PICTURE _IOW(MSM_CAM_IOCTL_MAGIC, 17, struct msm_camera_ctrl_cmd *) +#define MSM_CAM_IOCTL_GET_PICTURE _IOW(MSM_CAM_IOCTL_MAGIC, 17, struct msm_camera_ctrl_cmd *) -#define MSM_CAM_IOCTL_SET_CROP _IOW(MSM_CAM_IOCTL_MAGIC, 18, struct crop_info *) +#define MSM_CAM_IOCTL_SET_CROP _IOW(MSM_CAM_IOCTL_MAGIC, 18, struct crop_info *) -#define MSM_CAM_IOCTL_PICT_PP _IOW(MSM_CAM_IOCTL_MAGIC, 19, uint8_t *) +#define MSM_CAM_IOCTL_PICT_PP _IOW(MSM_CAM_IOCTL_MAGIC, 19, uint8_t *) -#define MSM_CAM_IOCTL_PICT_PP_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 20, struct msm_snapshot_pp_status *) +#define MSM_CAM_IOCTL_PICT_PP_DONE _IOW(MSM_CAM_IOCTL_MAGIC, 20, struct msm_snapshot_pp_status *) -#define MSM_CAM_IOCTL_SENSOR_IO_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 21, struct sensor_cfg_data *) +#define MSM_CAM_IOCTL_SENSOR_IO_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 21, struct sensor_cfg_data *) #define MSM_CAMERA_LED_OFF 0 #define MSM_CAMERA_LED_LOW 1 #define MSM_CAMERA_LED_HIGH 2 -#define MSM_CAM_IOCTL_FLASH_LED_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 22, unsigned *) +#define MSM_CAM_IOCTL_FLASH_LED_CFG _IOW(MSM_CAM_IOCTL_MAGIC, 22, unsigned *) -#define MSM_CAM_IOCTL_UNBLOCK_POLL_FRAME _IO(MSM_CAM_IOCTL_MAGIC, 23) +#define MSM_CAM_IOCTL_UNBLOCK_POLL_FRAME _IO(MSM_CAM_IOCTL_MAGIC, 23) -#define MSM_CAM_IOCTL_CTRL_COMMAND_2 _IOW(MSM_CAM_IOCTL_MAGIC, 24, struct msm_ctrl_cmd *) +#define MSM_CAM_IOCTL_CTRL_COMMAND_2 _IOW(MSM_CAM_IOCTL_MAGIC, 24, struct msm_ctrl_cmd *) #define MAX_SENSOR_NUM 3 #define MAX_SENSOR_NAME 32 @@ -168,6 +168,8 @@ struct msm_pmem_info { int type; int fd; void *vaddr; + uint32_t offset; + uint32_t len; uint32_t y_off; uint32_t cbcr_off; uint8_t active; -- cgit v1.1