libc

Why gdb cannot find ../sysdeps/unix/sysv/linux/ifaddrs.c

两盒软妹~` 提交于 2019-12-07 02:35:25
问题 I have libc6 & libc6-dbg installed. (gdb) b reak freeifaddrs (gdb) run Breakpoint 1, __freeifaddrs (ifa=0xa822e0) at ../sysdeps/unix/sysv/linux/ifaddrs.c:840 840 ../sysdeps/unix/sysv/linux/ifaddrs.c: No such file or directory. (gdb) list 835 in ../sysdeps/unix/sysv/linux/ifaddrs.c (gdb) disassemble Dump of assembler code for function __freeifaddrs: => 0x00007ffff7912fd0 <+0>: jmpq 0x7ffff780f8a8 End of assembler dump. (gdb) where #0 __freeifaddrs (ifa=0xa822e0) at ../sysdeps/unix/sysv/linux

call gettid witin glibc

Deadly 提交于 2019-12-07 02:04:08
问题 I am working in glibc and I need to get the id of the current thread. For this i use syscall(SYS_gettid); Issue is, i am forced to include bits/syscall.h instead of ideal case i.e sys/syscall.h . sys/syscall.h internally calls bits/syscall.h but that is wrapped with #ifndef _LIBC macro. i.e #ifndef _LIBC /* The Linux kernel header file defines macros `__NR_<name>', but some programs expect the traditional form `SYS_<name>'. So in building libc we scan the kernel's list and produce <bits

rand() is not returning random values

做~自己de王妃 提交于 2019-12-06 09:28:35
Its a small code to generate a random hermitian matrix hermitian matrix . I have called srand() before every call to rand(). but still no randomness in the output. I have used c99's complex datatype feature to create a hermitian matrix. I'm not sure where i'm wrong :( #include <stdio.h> #include <math.h> #include <complex.h> #include <stdlib.h> #include <time.h> #define MATSIZE 5 #define RAND_RANGE 100 double complex mat[MATSIZE][MATSIZE]; void gen_mat() { int i =0,j; int real; int img; for( ;i < MATSIZE; i++) { srand(time(NULL)); real = rand()%RAND_RANGE + 1; srand(time(NULL)); img = rand()

Debugging postgresql for where 'A' < 'a'

天大地大妈咪最大 提交于 2019-12-06 09:14:32
In a simple comparison test in postgres 9.1 and 8.4 is get the following weird results. postgres=# select 1 one where 'A' < 'a'; one ----- (0 rows) // ..... I would have expected 1 row postgres=# select 1 one where 'A' < 'b'; one ----- 1 (1 row) // ...... this looks OK postgres=# select 1 one where 'A' = 'a'; one ----- (0 rows) // ...... This also looks OK postgres=# select 1 one where 'A' > 'a'; one ----- 1 (1 row) // ...... This is inconsistent with the above results The ascii value of 'A' is 0x41 and 'a' is 0x61 so a straight comparison of ascii values should mean that 'A' is smaller than

How does a program inherit environment variables?

喜夏-厌秋 提交于 2019-12-06 08:11:32
When I use the function getenv() from the Standard C Library, my program inherit the environment variables from its parent. Example: $ export FOO=42 $ <<< 'int main() {printf("%s\n", getenv("FOO"));}' gcc -w -xc - && ./a.exe 42 In libc, the environ variable is declared into environ.c . I am expecting it to be empty at the execution, but I get 42 . Going a bit further getenv can be simplified as follow: char * getenv (const char *name) { size_t len = strlen (name); char **ep; uint16_t name_start; name_start = *(const uint16_t *) name; len -= 2; name += 2; for (ep = __environ; *ep != NULL; ++ep)

Libm relocation error when building Qt 5 for Nitrogen6x

只谈情不闲聊 提交于 2019-12-06 06:49:15
I am trying to build Qt 5 on a Nitrogen6x board powered by an *i.MX6Q`. I've installed Debian/wheezy on the board and am using an Ubuntu 12.10 machine for cross-compiling. Configuring Qt works like a charm but I am stuck in the make step. This is the configure script I run: ./configure -v -opensource -confirm-license -reduce-relocations -no-pch -no-xcb -no-opengl -opengl es2 -qt-libpng -qt-zlib -qt-xkbcommon -qt-xcb -qt-pcre -qt-libjpeg -qt-sql-mysql -optimized-qmake\ -make libs -device imx6 \ -compile-examples \ -device-option CROSS_COMPILE=/home/finn/gcc-linaro-arm-linux-gnueabihf-4.8-2013

Where did OSX's x86-64 assembly libc routines go?

ぃ、小莉子 提交于 2019-12-06 04:10:20
问题 First, some useful links to OSX's Libc code: Git: https://github.com/aosm/Libc.git (with tags for the different iterations of OSX) HTML: http://www.opensource.apple.com/source/Libc/ There, one can see that Libc 825.40.1 (OSX 10.8.5) still has public asm implementations of functions like memcpy. Notably in x86_64/string/bcopy_sse42.s . However, since version 997.1.1 (OSX 10.9), most of them seem to be gone. A few are left in x86_64/string though. As can be seen here: http://www.opensource

Installing a prebuilt binary on Android: “not found”

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 23:25:07
问题 I'm trying to install a prebuilt binary in a custom Android image. For that I have copied it to a new directory in prebuilt/android-arm/ with an Android.mk file similar to this one: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := binary_name LOCAL_MODULE := binary_name LOCAL_MODULE_CLASS := EXECUTABLES include $(BUILD_PREBUILT) So if I run make system_image binary_name , the binary file is copied to /bin/ in system image. And if I run the emulator I can see the binary

realloc but only first few bytes is meaningful

假如想象 提交于 2019-12-05 22:51:06
问题 Assume I have used ptr = malloc(old_size); to allocate a memory block with old_size bytes. Only the first header_size bytes is meaningful. I'm going to increase the size to new_size . new_size is greater than old_size and old_size is greater than header_size . before: /- - - - - - - old_size - - - - - - - \ +===============+---------------------+ \-header_size-/ after: /- - - - - - - - - - - - - - - new_size - - - - - - - - - - - - - - - - - - -\ +===============+-----------------------------

Understanding C errno

≯℡__Kan透↙ 提交于 2019-12-05 20:31:28
On my system errno defined as: int * __error(void); #define errno (* __error()) I understand errno is a macro and expands to * __error() function: I searched everywhere (source on my system) but I can't find the definition of the __error() function, can someone show/explain what would/should be the definition of it? How the expression errno = 0 works with the above definition (Assigning 0 to a function?)? Does errno = 0 expands to * __error() = 0 ? Thanks The __error function returns a pointer to the errno variable for the calling thread. The errno macro dereferences that pointer, resulting in