On 2015-07-03 14:38, Gilles Chanteperdrix wrote:
> On Fri, Jul 03, 2015 at 02:31:25PM +0200, Gilles Chanteperdrix wrote:
>> On Fri, Jul 03, 2015 at 12:51:49PM +0200, Gilles Chanteperdrix wrote:
>>>> index 0000000..36b1e69
>>>> --- /dev/null
>>>> +++ b/kernel/cobalt/posix/gen-syscall-entries.sh
>>>> @@ -0,0 +1,24 @@
>>>> +#! /bin/sh
>>>> +
>>>> +set -e
>>>> +
>>>> +shift
>>>> +
>>>> +echo "#ifdef COBALT_LIST_CALL_ENTRIES"
>>>> +awk '
>>>> +match($0, /COBALT_SYSCALL\([^,]*, [^,]*/)  {
>>>> +  str=substr($0, RSTART + 15, RLENGTH - 15)
>>>> +  match(str, /[^,]*/)
>>>> +  print "__COBALT_CALL_ENTRY(" substr(str, RSTART, RLENGTH) ")"
>>>> +}
>>>> +' $*
>>>> +echo "#endif"
>>>> +
>>>> +echo "#ifdef COBALT_LIST_MODES"
>>>> +awk '
>>>> +match($0, /COBALT_SYSCALL\([^,]*, [^,]*/)  {
>>>> +  str=substr($0, RSTART + 15, RLENGTH - 15)
>>>> +  print "__COBALT_MODE(" str ")"
>>>> +}
>>>> +' $*
>>>> +echo "#endif"
>>>
>>> This is particularly inelegant:
>>> - you do not need awk to do that, sed is sufficient
>>> - with using awk, you can generate the two files in one pass, and
>>> remove the #ifdefs trick;
>>> - I think the awk script should at least generate an error in case
>>> of parser error
>>>
>>> I will submit an awk script which does that.
>>
>> Ok, another awk script which does that:
>>
>> BEGIN {
>>      system("rm -f syscalls_modes.h syscalls_entries.h")
>> }
>>
>> match($0, /COBALT_SYSCALL\([^,]*,[ \t]*[^,]*/)  {
>>      str=substr($0, RSTART + 15, RLENGTH - 15)
>>      match(str, /[^, \t]*/)
>>      syscall=substr(str, RSTART, RLENGTH)
>>
>>      if (syscall == "") {
>>              print "Failed to find syscall name in line " $0
>>              exit 1
>>      }
>>
>>      print "__COBALT_MODE(" str ")," >> "syscalls_modes.h"
>>      print "__COBALT_CALL_ENTRY(" syscall ")," >> "syscalls_entries.h"
>>      next
>> }
>>
>> /COBALT_SYSCALL\(/  {
>>      print "Failed to parse line " $0
>>      exit 1
>> }
>>
>> It supposes it is running from the output directory, but we can pass
>> the output directory as a parameter if you prefer.
> 
> Note that the simplistic approach taken precludes the use of
> conditional compilation with syscall definitions.

I'll parametrize and integrate this, thanks.

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux

_______________________________________________
Xenomai mailing list
[email protected]
http://xenomai.org/mailman/listinfo/xenomai

Reply via email to