apache2 cross-build failed for arm - apache

On cross-building apache2 2.4.12 I get the following Error during complitation:
ptxdist/platform/build-target/httpd-2.4.12/modules/mappers -prefer-non-pic -static -c exports.c && touch exports.lo
exports.c:4117:55: error: 'apr_hash_this_key' undeclared here (not in a function)
exports.c:4121:59: error: 'apr_hash_this_key_len' undeclared here (not in a function)
exports.c:4125:55: error: 'apr_hash_this_val' undeclared here (not in a function)
exports.c:4568:62: error: 'apr_sockaddr_is_wildcard' undeclared here (not in a function)
exports.c:5307:55: error: 'apr_shm_create_ex' undeclared here (not in a function)
exports.c:5323:55: error: 'apr_shm_attach_ex' undeclared here (not in a function)
It seems that there is a dirty hack that generate httpd-2.4.12/server/exports.c during compile time from file make_exports.awk
How do I adjust this make_exports.awk file to get a working cross-build for arm?

The solution was to create a patch for apr-1.5.1 which disable apr_hash_this_key, apr_hash_this_key_len and so on. Then recompile apr, apr-util and apache 2.4.12.
diff -rupN AY/include/apr_hash.h AZ/include/apr_hash.h
--- AY/include/apr_hash.h 2015-02-27 10:35:07.436548295 +0100
+++ AZ/include/apr_hash.h 2015-02-27 10:33:30.038497258 +0100
## -171,21 +171,21 ## APR_DECLARE(void) apr_hash_this(apr_hash
* #param hi The iteration state
* #return The pointer to the key
*/
-APR_DECLARE(const void*) apr_hash_this_key(apr_hash_index_t *hi);
+//APR_DECLARE(const void*) apr_hash_this_key(apr_hash_index_t *hi);
/**
* Get the current entry's key length from the iteration state.
* #param hi The iteration state
* #return The key length
*/
-APR_DECLARE(apr_ssize_t) apr_hash_this_key_len(apr_hash_index_t *hi);
+//APR_DECLARE(apr_ssize_t) apr_hash_this_key_len(apr_hash_index_t *hi);
/**
* Get the current entry's value from the iteration state.
* #param hi The iteration state
* #return The pointer to the value
*/
-APR_DECLARE(void*) apr_hash_this_val(apr_hash_index_t *hi);
+//APR_DECLARE(void*) apr_hash_this_val(apr_hash_index_t *hi);
/**
* Get the number of key/value pairs in the hash table.
diff -rupN AY/include/apr_network_io.h AZ/include/apr_network_io.h
--- AY/include/apr_network_io.h 2013-12-06 18:10:34.000000000 +0100
+++ AZ/include/apr_network_io.h 2015-02-27 11:50:10.847966181 +0100
## -730,7 +730,7 ## APR_DECLARE(int) apr_sockaddr_equal(cons
* #remark The return value will be non-zero if the address is
* initialized and is the wildcard address.
*/
-APR_DECLARE(int) apr_sockaddr_is_wildcard(const apr_sockaddr_t *addr);
+//APR_DECLARE(int) apr_sockaddr_is_wildcard(const apr_sockaddr_t *addr);
/**
* Return the type of the socket.
diff -rupN AY/include/apr_shm.h AZ/include/apr_shm.h
--- AY/include/apr_shm.h 2015-02-27 12:00:01.119541200 +0100
+++ AZ/include/apr_shm.h 2015-02-27 12:02:01.294089137 +0100
## -111,12 +111,12 ## APR_DECLARE(apr_status_t) apr_shm_create
* function will return the first usable byte of memory.
*
*/
-APR_DECLARE(apr_status_t) apr_shm_create_ex(apr_shm_t **m,
+/*APR_DECLARE(apr_status_t) apr_shm_create_ex(apr_shm_t **m,
apr_size_t reqsize,
const char *filename,
apr_pool_t *pool,
apr_int32_t flags);
-
+*/
/**
* Remove named resource associated with a shared memory segment,
* preventing attachments to the resource, but not destroying it.
## -164,11 +164,11 ## APR_DECLARE(apr_status_t) apr_shm_attach
* structure for this process.
* #param flags mask of APR_SHM_* (defined above)
*/
-APR_DECLARE(apr_status_t) apr_shm_attach_ex(apr_shm_t **m,
+/*APR_DECLARE(apr_status_t) apr_shm_attach_ex(apr_shm_t **m,
const char *filename,
apr_pool_t *pool,
apr_int32_t flags);
-
+*/
/**
* Detach from a shared memory segment without destroying it.
* #param m The shared memory structure representing the segment
diff -rupN AY/Makefile.in AZ/Makefile.in
--- AY/Makefile.in 2015-02-27 10:17:32.817392979 +0100
+++ AZ/Makefile.in 2015-02-27 10:17:44.075619396 +0100
## -113,7 +113,7 ## apr.exp: exports.c export_vars.c
#echo "#! lib#APR_LIBNAME#.so" > $#
#echo "* This file was AUTOGENERATED at build time." >> $#
#echo "* Please do not edit by hand." >> $#
- $(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$$/\1/' >> $#
+ #$(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$$/\1/' >> $#
$(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$$/d' >> $#
dox:

Related

problem with sprint/printf with freeRTOS on stm32f7

Since two days I am trying to make printf\sprintf working in my project...
MCU: STM32F722RETx
I tried to use newLib, heap3, heap4, etc, etc. nothing works. HardFault_Handler is run evry time.
Now I am trying to use simple implementation from this link and still the same problem. I suppose my device has some problem with double numbers, becouse program run HardFault_Handler from this line if (value != value) in _ftoa function.( what is strange because this stm32 support FPU)
Do you guys have any idea? (Now I am using heap_4.c)
My compiller options:
target_compile_options(${PROJ_NAME} PUBLIC
$<$<COMPILE_LANGUAGE:CXX>:
-std=c++14
>
-mcpu=cortex-m7
-mthumb
-mfpu=fpv5-d16
-mfloat-abi=hard
-Wall
-ffunction-sections
-fdata-sections
-O1 -g
-DLV_CONF_INCLUDE_SIMPLE
)
Linker options:
target_link_options(${PROJ_NAME} PUBLIC
${LINKER_OPTION} ${LINKER_SCRIPT}
-mcpu=cortex-m7
-mthumb
-mfloat-abi=hard
-mfpu=fpv5-sp-d16
-specs=nosys.specs
-specs=nano.specs
# -Wl,--wrap,malloc
# -Wl,--wrap,_malloc_r
-u_printf_float
-u_sprintf_float
)
Linker script:
/* Highest address of the user mode stack */
_estack = 0x20040000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
}
UPDATE:
I don't think so it is stack problem, I have set configCHECK_FOR_STACK_OVERFLOW to 2, but hook function is never called. I found strange think: This soulution works:
float d = 23.5f;
char buffer[20];
sprintf(buffer, "temp %f", 23.5f);
but this solution not:
float d = 23.5f;
char buffer[20];
sprintf(buffer, "temp %f",d);
No idea why passing variable by copy, generate a HardFault_Handler...
You can implement a hard fault handler that at least will provide you with the SP location to where the issue is occurring. This should provide more insight.
https://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html
It should let you know if your issue is due to a floating point error within the MCU or if it is due to a branching error possibly caused by some linking problem
I also had error with printf when using FreeRTOS for my SiFive HiFive Rev B.
To solve it, I rewrite _fstat and _write functions to change output function of printf
/*
* Retarget functions for printf()
*/
#include <errno.h>
#include <sys/stat.h>
int _fstat (int file, struct stat * st) {
errno = -ENOSYS;
return -1;
}
int _write (int file, char * ptr, int len) {
extern int uart_putc(int c);
int i;
/* Turn character to capital letter and output to UART port */
for (i = 0; i < len; i++) uart_putc((int)*ptr++);
return 0;
}
And create another uart_putc function for UART0 of SiFive HiFive Rev B hardware:
void uart_putc(int c)
{
#define uart0_txdata (*(volatile uint32_t*)(0x10013000)) // uart0 txdata register
#define UART_TXFULL (1 << 31) // uart0 txdata flag
while ((uart0_txdata & UART_TXFULL) != 0) { }
uart0_txdata = c;
}
The newlib C-runtime library (used in many embedded tool chains) internally uses it's own malloc-family routines. newlib maintains some internal buffers and requires some support for thread-safety:
http://www.nadler.com/embedded/newlibAndFreeRTOS.html
hard fault can caused by unaligned Memory Access:
https://www.keil.com/support/docs/3777.htm

objcopy: bloated binary output file

While working on my bootloader project, I noticed that the resulting binary file is larger than the sum of the sizes of each section in the original ELF file.
After linking the bootloader image via ld, the ELF file is structured as follows:
$ readelf -S elfboot.elf
There are 10 section headers, starting at offset 0xa708:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00007e00 000e00 004bc7 00 AX 0 0 16
[ 2] .rodata PROGBITS 0000c9d0 0059d0 000638 00 A 0 0 32
[ 3] .initcalls PROGBITS 0000ec20 007c20 00000c 00 WA 0 0 4
[ 4] .exitcalls PROGBITS 0000ec30 007c30 00000c 00 WA 0 0 4
[ 5] .data PROGBITS 0000ec40 007c40 0001e0 00 WA 0 0 32
[ 6] .bss NOBITS 0000ee20 007e20 00025c 00 WA 0 0 32
[ 7] .symtab SYMTAB 00000000 007e20 0016e0 10 8 166 4
[ 8] .strtab STRTAB 00000000 009500 0011bb 00 0 0 1
[ 9] .shstrtab STRTAB 00000000 00a6bb 00004a 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
p (processor specific)
I noticed that there is a rather big gap (~7KB) between the sections .rodata and .initcalls. I also checked out the content of each section:
$ objdump -s elfboot.elf
[...]
Contents of section .rodata:
[...]
cfc0 23cf0000 80000000 2fcf0000 00010000 #......./.......
cfd0 3bcf0000 00020000 47cf0000 00040000 ;.......G.......
cfe0 54cf0000 00080000 61cf0000 00100000 T.......a.......
cff0 6ecf0000 00200000 7bcf0000 00400000 n.... ..{....#..
d000 89cf0000 00800000 ........
Contents of section .initcalls:
ec20 02b50000 6db50000 feac0000 ....m.......
Contents of section .exitcalls:
[...]
My linker script tells to align every section at a 16 byte (0x10) boundary. After
objcopy -O binary elfboot.elf elfboot.bin
the resulting binary contains a huge chunk of zero filled bytes at offset 0x5200 (0xd000 - 0x7e00) all the way to offset 0x6e20 (0xec20 - 0x7e00). Now that I know where the zero filled bytes come from, how do I remove them? For reference I added the verbose output of the linker step including the linker script used:
i686-elfboot-gcc -o elfboot.elf -T elfboot.ld ./src/arch/x86/bootstrap.o ./src/arch/x86/a20.o ./src/arch/x86/bda.o ./src/arch/x86/bios.o ./src/arch/x86/copy.o ./src/arch/x86/e820.o ./src/arch/x86/entry.o ./src/arch/x86/idt.o ./src/arch/x86/realmode_jmp.o ./src/arch/x86/setup.o ./src/arch/x86/opmode.o ./src/arch/x86/pic.o ./src/arch/x86/ptrace.o ./src/arch/x86/video.o ./src/core/bdev.o ./src/core/cdev.o ./src/core/elf.o ./src/core/input.o ./src/core/interrupt.o ./src/core/loader.o ./src/core/main.o ./src/core/module.o ./src/core/pci.o ./src/core/printf.o ./src/core/string.o ./src/core/symbol.o ./src/crypto/crc32.o ./src/drivers/ide/ide.o ./src/fs/fs.o ./src/fs/file.o ./src/fs/super.o ./src/fs/ramfs/ramfs.o ./src/fs/isofs/isofs.o ./src/lib/ata/libata.o ./src/lib/tmg/libtmg.o ./src/mm/memblock.o ./src/mm/page_alloc.o ./src/mm/slub.o ./src/mm/util.o -O2 -Wl,--verbose -nostdlib -lgcc
GNU ld (GNU Binutils) 2.31.1
Supported emulations:
elf_i386
elf_iamcu
opened script file elfboot.ld
using external linker script:
==================================================
OUTPUT_FORMAT(elf32-i386)
ENTRY(_arch_start)
SECTIONS
{
/*
* The boot stack starts at 0x6000 and grows towards lower addresses.
* The stack is designed to be only one page in size, which should be
* sufficient for the bootstrap stage.
*/
. = 0x6000;
__stack_start = .;
/*
* Buffer for reading files from the boot device. Usually boot devices
* are designed to read data in chunks of 0x200 (512) or 0x800 (2048)
* bytes. The buffer is large enough to read 4 512 or 2 2048 chunks of
* data from the disk.
*/
__buffer_start = .;
. = 0x7000;
__buffer_end = .;
/*
* Actual bootstrap stage code and data.
*/
. = 0x7E00;
__bootstrap_start = .;
.text ALIGN(0x10) : {
__text_start = .;
*(.text*)
__text_end = .;
}
.rodata ALIGN(0x10) : {
__rodata_start = .;
*(.rodata*)
__rodata_end = .;
}
/*
* This section is dedicated to all built-in modules. If a module will
* be included in the elfboot binary, the module_init function pointer
* of that module is placed in this section.
*
* Make sure to initialize built-in filesystems first as we need it to
* setup the root file system node.
*/
.initcalls ALIGN(0x10) : {
__initcalls_vfs_start = .;
/* Built-in file systems */
*(.initcalls_vfs*)
__initcalls_vfs_end = .;
__initcalls_dev_start = .;
/* Built-in devices */
*(.initcalls_dev*)
__initcalls_dev_end = .;
__initcalls_start = .;
/* Built-in modules */
*(.initcalls*)
__initcalls_end = .;
}
.exitcalls ALIGN(0x10) : {
__exitcalls_start = .;
*(.exitcalls*)
__exitcalls_end = .;
}
.data ALIGN(0x10) : {
__data_start = .;
*(.data*)
__data_end = .;
}
.bss ALIGN(0x10) : {
__bss_start = .;
*(.bss*)
__bss_end = .;
}
__bootstrap_end = .;
}
==================================================
attempt to open ./src/arch/x86/bootstrap.o succeeded
./src/arch/x86/bootstrap.o
attempt to open ./src/arch/x86/a20.o succeeded
./src/arch/x86/a20.o
attempt to open ./src/arch/x86/bda.o succeeded
./src/arch/x86/bda.o
attempt to open ./src/arch/x86/bios.o succeeded
./src/arch/x86/bios.o
attempt to open ./src/arch/x86/copy.o succeeded
./src/arch/x86/copy.o
attempt to open ./src/arch/x86/e820.o succeeded
./src/arch/x86/e820.o
attempt to open ./src/arch/x86/entry.o succeeded
./src/arch/x86/entry.o
attempt to open ./src/arch/x86/idt.o succeeded
./src/arch/x86/idt.o
attempt to open ./src/arch/x86/realmode_jmp.o succeeded
./src/arch/x86/realmode_jmp.o
attempt to open ./src/arch/x86/setup.o succeeded
./src/arch/x86/setup.o
attempt to open ./src/arch/x86/opmode.o succeeded
./src/arch/x86/opmode.o
attempt to open ./src/arch/x86/pic.o succeeded
./src/arch/x86/pic.o
attempt to open ./src/arch/x86/ptrace.o succeeded
./src/arch/x86/ptrace.o
attempt to open ./src/arch/x86/video.o succeeded
./src/arch/x86/video.o
attempt to open ./src/core/bdev.o succeeded
./src/core/bdev.o
attempt to open ./src/core/cdev.o succeeded
./src/core/cdev.o
attempt to open ./src/core/elf.o succeeded
./src/core/elf.o
attempt to open ./src/core/input.o succeeded
./src/core/input.o
attempt to open ./src/core/interrupt.o succeeded
./src/core/interrupt.o
attempt to open ./src/core/loader.o succeeded
./src/core/loader.o
attempt to open ./src/core/main.o succeeded
./src/core/main.o
attempt to open ./src/core/module.o succeeded
./src/core/module.o
attempt to open ./src/core/pci.o succeeded
./src/core/pci.o
attempt to open ./src/core/printf.o succeeded
./src/core/printf.o
attempt to open ./src/core/string.o succeeded
./src/core/string.o
attempt to open ./src/core/symbol.o succeeded
./src/core/symbol.o
attempt to open ./src/crypto/crc32.o succeeded
./src/crypto/crc32.o
attempt to open ./src/drivers/ide/ide.o succeeded
./src/drivers/ide/ide.o
attempt to open ./src/fs/fs.o succeeded
./src/fs/fs.o
attempt to open ./src/fs/file.o succeeded
./src/fs/file.o
attempt to open ./src/fs/super.o succeeded
./src/fs/super.o
attempt to open ./src/fs/ramfs/ramfs.o succeeded
./src/fs/ramfs/ramfs.o
attempt to open ./src/fs/isofs/isofs.o succeeded
./src/fs/isofs/isofs.o
attempt to open ./src/lib/ata/libata.o succeeded
./src/lib/ata/libata.o
attempt to open ./src/lib/tmg/libtmg.o succeeded
./src/lib/tmg/libtmg.o
attempt to open ./src/mm/memblock.o succeeded
./src/mm/memblock.o
attempt to open ./src/mm/page_alloc.o succeeded
./src/mm/page_alloc.o
attempt to open ./src/mm/slub.o succeeded
./src/mm/slub.o
attempt to open ./src/mm/util.o succeeded
./src/mm/util.o
attempt to open /home/croemheld/Repositories/elfboot/elfboot-toolchain/lib/gcc/i686-elfboot/8.2.0/libgcc.so failed
attempt to open /home/croemheld/Repositories/elfboot/elfboot-toolchain/lib/gcc/i686-elfboot/8.2.0/libgcc.a succeeded
(/home/croemheld/Repositories/elfboot/elfboot-toolchain/lib/gcc/i686-elfboot/8.2.0/libgcc.a)_umoddi3.o
(/home/croemheld/Repositories/elfboot/elfboot-toolchain/lib/gcc/i686-elfboot/8.2.0/libgcc.a)_udivmoddi4.o
Please note that I am not able to load the sections individually into memory, since my first stage bootloader (boot sector) simply loads the entire file at a specified offset from the boot device. To reduce the size of the second stage bootloader image, I want to try to remove the gap at link time or also if possible at all, at post link time (objcopy, ...).

JNI, How to access the current Java thread in JNI

is there a way to get Java thread(ID, name) from JNI. I am not talking about passing Thread.currentThread().getId() from java to JNI. Does JNI provide API to access currently running thread?
You can (as mentioned by Alex) resort to java.lang.Thread.
// First, we have to find Thread class
jclass cls = (*env)->FindClass(env, "java/lang/Thread");
// Then, we can look for it's static method 'currentThread'
/* Remember that you can always get method signature using javap tool
> javap -s -p java.lang.Thread | grep -A 1 currentThread
public static native java.lang.Thread currentThread();
descriptor: ()Ljava/lang/Thread;
*/
jmethodID mid =
(*env)->GetStaticMethodID(env, cls, "currentThread", "()Ljava/lang/Thread;");
// Once you have method, you can call it. Remember that result is
// a jobject
jobject thread = (*env)->CallStaticObjectMethod(env, cls, mid);
if( thread == NULL ) {
printf("Error while calling static method: currentThread\n");
}
// Now, we have to find another method - 'getId'
/* Remember that you can always get method signature using javap tool
> javap -s -p java.lang.Thread | grep -A 1 getId
public long getId();
descriptor: ()Jjavap -s -p java.lang.Thread | grep -A 1 currentThread
*/
jmethodID mid_getid =
(*env)->GetMethodID(env, cls, "getId", "()J");
if( mid_getid == NULL ) {
printf("Error while calling GetMethodID for: getId\n");
}
// This time, we are calling instance method, note the difference
// in Call... method
jlong tid = (*env)->CallLongMethod(env, thread, mid_getid);
// Finally, let's call 'getName' of Thread object
/* Remember that you can always get method signature using javap tool
> javap -s -p java.lang.Thread | grep -A 1 getName
public final java.lang.String getName();
descriptor: ()Ljava/lang/String;
*/
jmethodID mid_getname =
(*env)->GetMethodID(env, cls, "getName", "()Ljava/lang/String;");
if( mid_getname == NULL ) {
printf("Error while calling GetMethodID for: getName\n");
}
// As above, we are calling instance method
jobject tname = (*env)->CallObjectMethod(env, thread, mid_getname);
// Remember to retrieve characters from String object
const char *c_str;
c_str = (*env)->GetStringUTFChars(env, tname, NULL);
if(c_str == NULL) {
return;
}
// display message from JNI
printf("[C ] name: %s id: %ld\n", c_str, tid);
// and make sure to release allocated memory before leaving JNI
(*env)->ReleaseStringUTFChars(env, tname, c_str);
You can find full sample here: https://github.com/mkowsiak/jnicookbook/tree/master/recipes/recipeNo044

Cannot set Attribute Permissions to 0666 in sysfs

I am working with sysfs and I need to create a file under sysfs, the file should be readable and writable by all users, for which I set the Permissions in '__ATTR' to 0666. But the module does not compile, the moment I change the permissions to 0660, it compiles correctly.
The Error message that I get with 0666 permissions is as follows
`/home/rishabh/kernel_modules/Task09/task9.c: At top level:
include/linux/bug.h:33:45: error: negative width in bit-field ‘<anonymous>’
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
^
include/linux/kernel.h:859:3: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
BUILD_BUG_ON_ZERO((perms) & 2) + \
^
include/linux/sysfs.h:102:12: note: in expansion of macro ‘VERIFY_OCTAL_PERMISSIONS’
.mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
^
/home/rishabh/kernel_modules/Task09/task9.c:65:2: note: in expansion of macro ‘__ATTR’
__ATTR(id, 0666, id_show, id_store);
^
include/linux/bug.h:33:45: warning: initialization from incompatible pointer type [enabled by default]
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
^
include/linux/kernel.h:859:3: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
BUILD_BUG_ON_ZERO((perms) & 2) + \
^
include/linux/sysfs.h:102:12: note: in expansion of macro ‘VERIFY_OCTAL_PERMISSIONS’
.mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
^
/home/rishabh/kernel_modules/Task09/task9.c:65:2: note: in expansion of macro ‘__ATTR’
__ATTR(id, 0666, id_show, id_store);
^
include/linux/bug.h:33:45: warning: (near initialization for ‘id_attribute.show’) [enabled by default]
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
^
include/linux/kernel.h:859:3: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
BUILD_BUG_ON_ZERO((perms) & 2) + \
^
include/linux/sysfs.h:102:12: note: in expansion of macro ‘VERIFY_OCTAL_PERMISSIONS’
.mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
^
/home/rishabh/kernel_modules/Task09/task9.c:65:2: note: in expansion of macro ‘__ATTR’
__ATTR(id, 0666, id_show, id_store);
^
`
I also tried using __ATTR_RW(_name) macro, but it gives read-write permissions only to root and all others are left with read permission.
If you follow the error messages, the 2nd one is
kernel.h:859:3: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
BUILD_BUG_ON_ZERO((perms) & 2)
and if you look in kernel.h you will see the comment
#define VERIFY_OCTAL_PERMISSIONS(perms)
...
/* OTHER_WRITABLE? Generally considered a bad idea. */ \
BUILD_BUG_ON_ZERO((perms) & 2) + \
...
So you can see that you are being told that it is a bad idea to make a sysfs file writeable to all. If you really want to do this, you must bypass this macro check. For example, add just before your call of __ATTR() a redefinition of the macro:
/* warning! need write-all permission so overriding check */
#undef VERIFY_OCTAL_PERMISSIONS
#define VERIFY_OCTAL_PERMISSIONS(perms) (perms)
__ATTR_RW(id) should be a correct way (and eudyptula accepted that ;)). Definition in sysfs.h says, that it set rights to 0644, which are correct rights you want - no one, except root user, can't write to /sys/kernel files (and it's specified in the task too).
sysfs.h part:
#define __ATTR_RW(_name) __ATTR(_name, (S_IWUSR | S_IRUGO), \
_name##_show, _name##_store)

Not getting appledoc to document NS_ENUM

could someone please explain what I am doing wrong when documenting my typedef NS_ENUM?
This is my syntax:
/** The different menu items
*/
typedef NS_ENUM(NSInteger, kMenuItem) {
/** The start page */
kMenuItemStartPage = 0,
/** The new round item */
kMenuItemNewRound,
/** The archive item */
kMenuItemArchive,
/** The participants item */
kMenuItemMyParticipants,
/** The locations item */
kMenuItemMyLocations,
/** The settings */
kMenuItemSettings,
/** The contact page */
kMenuItemContact,
/** The count */
kMenuItemTotal
};
/**
* This is the Menu View Controller.
*
* The menu view controller handles the menu the menu and its options. You can access the menu view controller using the `menuContainer` in the `ApplicationDelegate`
*
*/
#interface MenuTVC : UITableViewController
#end
My run script build phase:
APPLEDOC_PATH=`which appledoc`
if [ $APPLEDOC_PATH ]; then
echo "Generating docs!";
$APPLEDOC_PATH \
--project-name "${PRODUCT_NAME}" \
--project-company "Sogeti Sverige AB" \
--company-id "se.domain.project" \
--output "Docs" \
--no-install-docset \
--exit-threshold "2" \
--keep-undocumented-objects \
--keep-undocumented-members \
--keep-intermediate-files \
--ignore "Pods" \
--ignore ".m" \
--index-desc "${PROJECT_DIR}/Readme.md" \
${PROJECT_DIR}/Prevent
else
echo "AppleDoc not found or installed!"
fi;
The result:
And build result:
From the terminal:
$ which appledoc
/usr/bin/appledoc
$ appledoc --version
appledoc version: 2.2 (build 963)
I just can't seem to figure it out.
Thanks in advance!
I just figured out that the enums are documented in the index.html file, and not the class documentation itself.
It does work.
Appledoc doesn't currently support enums. It's quite a, shall we say, popular feature request:
https://github.com/tomaz/appledoc/issues/2