OS/2 codes: How to override standard functions in kLIBC

Sometimes there is a time when it is needed to override the functionality of some functions. To do this, at least two ways can be considered. Macros First is to use macros. For examples, if you want to override pipe(), then you can write the codes like this. Colored By Color Scripter ™ 1 2 3 4 5 6 7 8 9 10 #include  <io.h> int  my_pipe( int  *ph) {     some_codes;      return  (pipe)(ph); } #define  pipe(ph) my_pipe(ph) At line 7, a parenthesis is used to prevent pipe() from being expaned to my_pipe() by a macro. This way has an advantage that this can be applied to all the functions. But this has a disadvantage that this can be applied only locally. If you want to apply globally, then you should create a header for a macro and all the sources should include that header. Alias The other way is to use alias. kLIBC provides aliases for standard functions, which do not ha...

OS/2 codes: How to link statically against kLIBC

Originally, it is not supposed to link statically against kLIBC. That is, all the programs linked against kLIBC will depend on libcxxx.dll. Neverthelss, it is not impossible. Do the following. gcc -Zomf -static -o test.exe test.c -lc_omf386 Then, you can get test.exe without dependency on libcxxx.dll.

GNU Make 와 gcc 를 이용한 멀티 타겟 Makefile 만들기

예전에 GNU Make 와 gcc 를 이용한 auto-dependency Makefile 만들기 를 썼었는데, 이것은 단지 하나의 타겟만을 만들 수 있었다. 이번에는 이 부분을 개선해서 멀티 타겟 Makefile 을 만들어보자. 멀티 타겟을 지원하기 위해서는 GNU Make 의 몇 가지 함수를 먼저 살펴볼 필요가 있다. foreach 함수 foreach 함수의 문법은 다음과 같다. $(foreach var,list,text) 기능은 list 의 내용을 빈 칸을 기준으로 구분해서 var 에 각각 대입하고, 매번 text 를 확장한다. 예를 들면, l := $(foreach d,a b c d,l $(d)) 이 경우, l 은 l a l b l c l d 가 된다. call 함수 call 함수의 문법은 다음과 같다. $(call var,param,param,...) call 함수는 var 를 일종의 함수처럼 처리한다. var 뒤의 param 들은 var 의 $(1), $(2), ... 로 대체된다. 예를 들면, merge = $(1)/$(2) path := $(call merge,a,b) 이 경우 path 는 a/b 가 된다. define 지시자 define 지시자와 endef 를 통해 멀티 라인 변수를 만들 수 있다. 다음과 같이 쓰인다. define m echo foo echo $(boo) endef 만일 call 함수와 함께 쓰인다면 보통의 함수와 같은 역할을 할 수 있다. eval 함수 eval 함수의 문법은 다음과 같다. $(eval text) eval 함수는 text 의 내용을 Make 파일의 일부로 해석하게 만든다. 예를 들면, .PHONY: all define a all:     echo hello endef $(eval $(a)) 이것은 다음처럼 처리된다. .PHONY: all all: ...

Porting to OS/2: Case #17 spawn...()

Many Unix programs seem not to care about command line length. So sometimes they pass a very long command line to a child program. However, OS/2 has a limitation for a command line length. It's 32KB. If a length is longer than 32KB, then OS/2 cannot execute a child program. If so, there is no way to workaround this ? Fortunately, there is a way in case of kLIBC. kLIBC supports a response file as an argument. Instead of passing arguments to a child program directly, passing arguments via a response file is the way. Here is spwanvpe() to pass a very long command line as a response file. https://github.com/komh/os2compat/blob/master/process/spawnvpe.c And a test program. https://github.com/komh/os2compat/blob/master/testcase/spawnvpe-1.c https://github.com/komh/os2compat/blob/master/testcase/spawnvpe-1-child.c How to build spawnvpe-1.exe gcc spwanvpe-1.c spawnvpe.c How to build spawnvpe-1-child.c gcc spawnvpe-1-child.c Other spawnl...() and spawnv...() can ...

OS/2 tricks: Useful git settings

git is more and more used in open source projects. Fortuantely, git is available on OS/2, too. Here, I would introduce some useful settings on OS/2. core.autocrlf This sets how to process eol. If this is false, git does not convert eol at all. If it is true, eol is converted to LF on check-in, but converted to CR/LF on check-out. This is useful, but sometimes some shell scripts or unixy programs trigger errors due to eol problem. This is because shells and programs ported to OS/2, do not process eol with unified way. If it is input, eol is converted to LF on check-in, but git does not care eol of files in a working tree. I recommend this. but remember that REXX scripts should have CR/LF eol. For this, append [*.cmd eol=crlf] to .gitattributes file. In order to set, use this command, git config --global core.autocrlf input apply.whitespace EOL is always a problem. Some git commands refuse to process tasks due to whitespace, Primarily CR/LF. But, if you set this var...

OS/2 tricks: How to run foreign shell scripts

Generally, what to do in order to run foreign shell scripts is to run shell scripts with a shell script processor. For examples, if you want to run a shell script, test.sh for sh, then you should do sh shtest.sh But OS/2 provides a special keyword to ease this. That is extproc . By default OS/2 has two script processorst. One is a batch processor, the other one is REXX.  However, with extproc, OS/2 can process other scripts than a batch and a REXX. extproc is similar to #! of Unix worlds. If the first line of a script file is extproc, then the remaining parts are treated as an script processors. Notice that scripts files should have .cmd extension. For examples, the above command can be written like this, shtest.cmd ----- extproc sh ... orignal stuffs of test.sh ... ----- Then, you can excute shtest.cmd directly with OS/2 command processors such as CMD.EXE or 4OS2.EXE. In pratice, shtest.cmd is executed like this by OS/2, sh shtest.cmd Sometimes, extproc ...

왕좌의 게임(원작: 얼음과 불의 노래) 해설 방송

팟캐스트 방송 '그것은 알기 싫다' 에서 물뚝심송님께서 해설 방송을 하고 있다. 드라마 내용 이전의 역사와 전체적인 흐름에 대해 원작 소설과 여타 추론 등을 이용해 설명해 준다. 아울러 소설이 그러하듯, 이 작품 속에 아로 새겨진 우리가 살고 있는 세상의 모습을 살펴본다. 팟캐스트 방송: 그것은 알기 싫다 에서 '얼음과 불의 잉해' 라는 제목으로 올라와 있다.  10월 17일자로 마무리되었다.

< 공각기동대 > 를 보고...

‘공각기동대’ 를 보았다. 그런데 특이한 것은 애니의 어디를 보아도 ‘공각기동대’ 라는 말은 찾을 수가 없었다. 혹시 해적판 ? 명시적인 제목은 ‘Ghost in the Shell' 이었다. 그동안 많은 사람들의 입에서 오르내리던 작품이라 기대도 컸고, 어떤 두려움도 많았다. 단 한 번을 보고서 어떤 이야기를 쓴다는 것이 참으로 우스운 이야기이긴 하지만 그래도 느낌이니까. 한마디로 말하자면, ‘공각기동대’ 는 디지털 문명 속의 ‘실존’ 에 관한 질문이다. 몇가지 재미있는 질문들이 나온다. ‘생명’ 의 정의 ? 인형사와 6과에 있는 사람들과의 대화 속에서 각자의 생명관이 드러난다. 아마도 6 과 사람들이 고전적인 생명관을 유지하고 있다면, 인형사 - 그 위상상 - 는 보다 진보적(?)인 생명관을 주장한다. 6과들은 이렇게 얘기한다. 인간의 손으로 만들어진 것은 생명이 아니다. 너는 단지 프로그램일 뿐이다. 하지만 인형사는 이렇게 얘기한다. 비록 내가 6과의 방어벽 - 용어가 정확치 않음 ^^; - 에 쫓겨 이 곳에 있지만, 이 곳에 남은 것은 내 의지이다. 따라서 난 하나의 생명체이다. 인공성(artificiality)과 진정성(authenticity)의 대립. 인형사의 의미 심장한 한마디. ‘너희는 새로운 생명관을 확립하는 것에 소홀했다’ ‘공각기동대’ 에는 여러 종류의 생명 모델이 나온다. 순수(?) 인간, 몸의 많은 부분이 의체로 구성된 인간, 영혼을 해킹당한 인간, 인간의 통제를 벗어난 프로그램. ‘공각기동대’ 는 바로 이들 사이에 존재하는 생명의 경계를 묻고 있다. 참으로 인상적인 말. ‘과학은 생명을 정의할 수 없다’. 이 말은 차라리 지금의 과학 수준을 꼬집는 것이라기 보다는 과학에만 의존하는 생명관을 비판한다고 보아야 할 것이다. 공각기동대는 비록 우리가 생물학 수준에서 논의되고 있는 생명관조차도 많은 혼란을 겪고 있지만 이보다 나아가서 기계 수준, 더 나아가 인공지능과 디지털 문명의 발달 속에서 예견되는 디지털 생명을...

< X 파일 > [ 회색지대 ] 편을 보고...

‘X 파일’은 그 제목에서 느껴지는 것처럼 참으로 많은 해석의 여지를 가지고 있다. 이번 주( 10 월 04 일 ) 에 방영되었던 ‘회색지대’ 역시 마찬가지이다. 일단 ‘회색지대’ 라는 제목이 어떤 의미를 가지고 있는가는 미루어 두기로 하자. 내용의 시작은 이렇다. ‘브라운산’을 올랐던 한 부부가 유골만 남은 채 발견된다. 당연히 이 사건은 멀더와 스컬리에게 맡겨지고, 역시 당연히 이들은 각자의 입장( 멀더는 신비주의, 스컬리는 과학주의 ) 에 입각해서 사건을 풀어나가려고 한다. 언제나처럼 둘은 충돌하지만, 역시 언제나처럼 사건은 풀리기 시작한다. 먼저 멀더는 시체 부검을 하는 스컬리를 떠나서 홀로 브라운산을 오른다. 놀랍게도 그 곳에서 이미 유골이 발견된 부부의 남편을 발견하고 그를 뒤쫓는다. 그 남편은 어느 동굴 속으로 들어가고, 멀더 역시 그를 뒤따른다. 기어코 남편을 만나게 되고, 멀더가 그로부터 듣게 되는 얘기는 멀더가 진실이라고 여기는 바로 그것이다. 이 때 어디선가 빛이 들어오게 되는데, 그 남편은 그들이라고 얘기하면 숨지만, 멀더는 ( 원래 주인공들은 다 강심장인가 ? ) 그 빛을 쫓아간다. 극 속에서 그 빛은 멀더를 찾아온 스컬리의 손전등 빛이라는 암시를 준다. 갑자기 화면이 바뀌며, 스컬리가 멀더의 방문을 두드린다. 방문은 열리고, 스컬리는 멀더의 방에 있는 부부를 보고 놀란다. 게다가 멀더가 숨겨놓은 외계인을 보며, 또 그와 텔레파시가 통하며 자신이 믿어왔던 모든 가치관을 부정해 버리며, 멀더가 옳았음을 인정한다. 그런데 멀더는 자신이 그렇게 주장하던 것들이 진실로써 판명되고 있음에도 불구하고, 의아함을 느낀다. 그리고 그는 머리에 통증을 느낀다. 하나씩 사라지는 주위 환경을 보며. 이번에는 스컬리. 스컬리는 멀더를 찾아서 브라운산으로 올라간다. 올라가던 도중 야생 버섯의 포자를 밟는다. 그리고 땅속에서 솟아나는 액체를 발견한다. 이 때 스컬리는 전에 없던 유골을 발견하게 되고, 그 유골이 멀더의 것임을 알게 된다. 이 때 같...