Re: [racket-dev] ffi vectors
When you run this program on a 32-bit machine: #include stdio.h void go(float a[4]) { printf(in go: %d\n, sizeof(a)); } int main() { float a[4]; printf(in main: %d\n, sizeof(a)); go(a); } you'll see in main: 16 and in go: 4. As far as I know, the 4 in void go(float a[4]) is ignored. It's really the same as void go(float a[]) or void go(float *a). Unless the declaration of an array variable is allocating the variable, the variable is really a pointer, and sizeof() reflects that. Along the same lines, a `_cvector' in the FFI always has a pointer size, because it's always like a pointer. A `(_cvector o _float 4)' or `(_f32vector o 4)' is probably what you want, if the function you'll calling fills in the vector. A `_float4-pointer' (not `_float4'!) if you allocate it yourself or `(_pointer o _float4)' is also fine. At Thu, 30 Sep 2010 16:41:29 -0600, Jay McCarthy wrote: I'd like to be able to define ctypes like I would make a typedef in C like typedef float float4[4]; But it doesn't seem like this works in the FFI. See the program below with its awkward work-around: #lang racket (require ffi/unsafe ffi/unsafe/cvector ffi/vector tests/eli-tester) (test (ctype-sizeof _float) = 4 (ctype-sizeof _cvector) = 4 (ctype-sizeof (_cvector i _float)) = 4 (ctype-sizeof (_cvector o _float 4)) = (* 4 4) (ctype-sizeof (_cvector io _float 4)) = (* 4 4) (ctype-sizeof _f32vector) = 4 (ctype-sizeof (_f32vector i)) = 4 (ctype-sizeof (_f32vector o 4)) = (* 4 4) (ctype-sizeof (_f32vector io 4)) = (* 4 4) (local [(define-cstruct _float4 ([f0 _float] [f1 _float] [f2 _float] [f3 _float]))] (test (ctype-sizeof _float4) = 16))) Output is: test: 5/11 test failures: unsaved-editor4119:11:1: test failure in (ctype-sizeof (_cvector i _float)) expected: 4 got: error: expand: unbound identifier in module unsaved-editor4119:12:1: test failure in (ctype-sizeof (_cvector o _float 4)) expected: 16 got: 4 unsaved-editor4119:13:1: test failure in (ctype-sizeof (_cvector io _float 4)) expected: 16 got: error: expand: unbound identifier in module unsaved-editor4119:17:1: test failure in (ctype-sizeof (_f32vector o 4)) expected: 16 got: 4 unsaved-editor4119:18:1: test failure in (ctype-sizeof (_f32vector io 4)) expected: 16 got: error: expand: unbound identifier in module Normally I would just go do this, but I don't really understand the FFI. If someone can point me appropriately, I'll go do it. Jay -- Jay McCarthy j...@cs.byu.edu Assistant Professor / Brigham Young University http://teammccarthy.org/jay The glory of God is Intelligence - DC 93 _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
[racket-dev] slideshow not hiding KDE panel
I'm trying to use slideshow on Linux, and I find it annoying that it fails to be on top of the KDE panel. I admit I know next to nothing about the X protocol, and can't help much with this issue, but I hope someone who does can do something about it. For the record, samth says he has the exact same problem with the GNOME panel. PS: I found it nice to be able to edit in Emacs and run the slideshow with slideshow foo.rkt or mred foo.rkt. Thanks a lot! [ François-René ÐVB Rideau | ReflectionCybernethics | http://fare.tunes.org ] Ob(Pure Programming Languages): implicit state _is_ modularity. If we want to be really radical, and eliminate implicit state, then we should eliminate it at the meta-level, too, and remove named variables, leaving us only combinators. (\Pi (S (K \Pi) (S (S (K S) (S (K K) (S (K P) I))) (S (S (K S) (S (K (S (K P))) (S (S (K S) (S (K K) (S (K P) I))) (K I (K I) _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] ffi vectors
I guess I misunderstood what you were looking for. It would be nice to have a compact ctype that adapts like the C array type to different contexts. For my FFI tasks, I've gotten by with structure types like `_float4'; I manually choose between `_float4' or `_float4-pointer' as needed in different contexts (the former for `malloc' or a struct member, the latter for a function argument or result). That strategy was was particularly awkward for a struct that contained an array of 32 bytes, though. At Thu, 30 Sep 2010 17:19:43 -0600, Jay McCarthy wrote: Yes, but this program: typedef float float4[4]; typedef struct { float4 a; float b; } astruct; void go(float4 a, astruct b) { printf(in go: %d\n, sizeof(a)); printf(in go: %d\n, sizeof(float4)); printf(in go: %d\n, sizeof(b)); printf(in go: %d\n, sizeof(astruct)); } int main() { float4 a; astruct b; printf(in main: %d\n, sizeof(a)); printf(in main: %d\n, sizeof(float4)); printf(in main: %d\n, sizeof(b)); printf(in main: %d\n, sizeof(astruct)); go(a, b); } produces in main: 16 in main: 16 in main: 20 in main: 20 in go: 8 in go: 16 in go: 20 in go: 20 The FFI is not just used for making function calls, it is also used for specify structures and malloc-ing on behalf of the functions you want to call. It is very awkward to make cstructs that are the correct size and malloc the right amount without similar functionality to C in this regard. Jay On Thu, Sep 30, 2010 at 4:51 PM, Matthew Flatt mfl...@cs.utah.edu wrote: When you run this program on a 32-bit machine: #include stdio.h void go(float a[4]) { printf(in go: %d\n, sizeof(a)); } int main() { float a[4]; printf(in main: %d\n, sizeof(a)); go(a); } you'll see in main: 16 and in go: 4. As far as I know, the 4 in void go(float a[4]) is ignored. It's really the same as void go(float a[]) or void go(float *a). Unless the declaration of an array variable is allocating the variable, the variable is really a pointer, and sizeof() reflects that. Along the same lines, a `_cvector' in the FFI always has a pointer size, because it's always like a pointer. A `(_cvector o _float 4)' or `(_f32vector o 4)' is probably what you want, if the function you'll calling fills in the vector. A `_float4-pointer' (not `_float4'!) if you allocate it yourself or `(_pointer o _float4)' is also fine. At Thu, 30 Sep 2010 16:41:29 -0600, Jay McCarthy wrote: I'd like to be able to define ctypes like I would make a typedef in C like typedef float float4[4]; But it doesn't seem like this works in the FFI. See the program below with its awkward work-around: #lang racket (require ffi/unsafe ffi/unsafe/cvector ffi/vector tests/eli-tester) (test (ctype-sizeof _float) = 4 (ctype-sizeof _cvector) = 4 (ctype-sizeof (_cvector i _float)) = 4 (ctype-sizeof (_cvector o _float 4)) = (* 4 4) (ctype-sizeof (_cvector io _float 4)) = (* 4 4) (ctype-sizeof _f32vector) = 4 (ctype-sizeof (_f32vector i)) = 4 (ctype-sizeof (_f32vector o 4)) = (* 4 4) (ctype-sizeof (_f32vector io 4)) = (* 4 4) (local [(define-cstruct _float4 ([f0 _float] [f1 _float] [f2 _float] [f3 _float]))] (test (ctype-sizeof _float4) = 16))) Output is: test: 5/11 test failures: unsaved-editor4119:11:1: test failure in (ctype-sizeof (_cvector i _float)) expected: 4 got: error: expand: unbound identifier in module unsaved-editor4119:12:1: test failure in (ctype-sizeof (_cvector o _float 4)) expected: 16 got: 4 unsaved-editor4119:13:1: test failure in (ctype-sizeof (_cvector io _float 4)) expected: 16 got: error: expand: unbound identifier in module unsaved-editor4119:17:1: test failure in (ctype-sizeof (_f32vector o 4)) expected: 16 got: 4 unsaved-editor4119:18:1: test failure in (ctype-sizeof (_f32vector io 4)) expected: 16 got: error: expand: unbound identifier in module Normally I would just go do this, but I don't really understand the FFI. If someone can point me appropriately, I'll go do it. Jay -- Jay McCarthy j...@cs.byu.edu Assistant Professor / Brigham Young University http://teammccarthy.org/jay The glory of God is Intelligence - DC 93 _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev -- Jay McCarthy j...@cs.byu.edu Assistant Professor / Brigham Young University http://teammccarthy.org/jay The glory of God is Intelligence - DC 93 _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] slideshow not hiding KDE panel
At Thu, 30 Sep 2010 20:20:07 -0400, Faré wrote: I'm trying to use slideshow on Linux, and I find it annoying that it fails to be on top of the KDE panel. I admit I know next to nothing about the X protocol, and can't help much with this issue, but I hope someone who does can do something about it. For the record, samth says he has the exact same problem with the GNOME panel. I think I could fix this in GRacket2 if I could figure out how to provoke the bad behavior on my machine. I'm running Ubuntu 10, and Slideshow works. I tried installing and running Maximus, but Slideshow still worked. (Robby showed me bad behavior on his netbook, and I thought it had something to do with Maximus, but it's apparently not as simple as that.) Does anyone know what I can do to trigger the problem? _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev
Re: [racket-dev] ffi vectors
Okay. I'm kind of glad that I came up with the normal thing. I'll put it on my infinitely long list of TODO items to come back and extend the ctypes so that they can specify both aspects of their size. Jay On Thu, Sep 30, 2010 at 7:25 PM, Matthew Flatt mfl...@cs.utah.edu wrote: I guess I misunderstood what you were looking for. It would be nice to have a compact ctype that adapts like the C array type to different contexts. For my FFI tasks, I've gotten by with structure types like `_float4'; I manually choose between `_float4' or `_float4-pointer' as needed in different contexts (the former for `malloc' or a struct member, the latter for a function argument or result). That strategy was was particularly awkward for a struct that contained an array of 32 bytes, though. At Thu, 30 Sep 2010 17:19:43 -0600, Jay McCarthy wrote: Yes, but this program: typedef float float4[4]; typedef struct { float4 a; float b; } astruct; void go(float4 a, astruct b) { printf(in go: %d\n, sizeof(a)); printf(in go: %d\n, sizeof(float4)); printf(in go: %d\n, sizeof(b)); printf(in go: %d\n, sizeof(astruct)); } int main() { float4 a; astruct b; printf(in main: %d\n, sizeof(a)); printf(in main: %d\n, sizeof(float4)); printf(in main: %d\n, sizeof(b)); printf(in main: %d\n, sizeof(astruct)); go(a, b); } produces in main: 16 in main: 16 in main: 20 in main: 20 in go: 8 in go: 16 in go: 20 in go: 20 The FFI is not just used for making function calls, it is also used for specify structures and malloc-ing on behalf of the functions you want to call. It is very awkward to make cstructs that are the correct size and malloc the right amount without similar functionality to C in this regard. Jay On Thu, Sep 30, 2010 at 4:51 PM, Matthew Flatt mfl...@cs.utah.edu wrote: When you run this program on a 32-bit machine: #include stdio.h void go(float a[4]) { printf(in go: %d\n, sizeof(a)); } int main() { float a[4]; printf(in main: %d\n, sizeof(a)); go(a); } you'll see in main: 16 and in go: 4. As far as I know, the 4 in void go(float a[4]) is ignored. It's really the same as void go(float a[]) or void go(float *a). Unless the declaration of an array variable is allocating the variable, the variable is really a pointer, and sizeof() reflects that. Along the same lines, a `_cvector' in the FFI always has a pointer size, because it's always like a pointer. A `(_cvector o _float 4)' or `(_f32vector o 4)' is probably what you want, if the function you'll calling fills in the vector. A `_float4-pointer' (not `_float4'!) if you allocate it yourself or `(_pointer o _float4)' is also fine. At Thu, 30 Sep 2010 16:41:29 -0600, Jay McCarthy wrote: I'd like to be able to define ctypes like I would make a typedef in C like typedef float float4[4]; But it doesn't seem like this works in the FFI. See the program below with its awkward work-around: #lang racket (require ffi/unsafe ffi/unsafe/cvector ffi/vector tests/eli-tester) (test (ctype-sizeof _float) = 4 (ctype-sizeof _cvector) = 4 (ctype-sizeof (_cvector i _float)) = 4 (ctype-sizeof (_cvector o _float 4)) = (* 4 4) (ctype-sizeof (_cvector io _float 4)) = (* 4 4) (ctype-sizeof _f32vector) = 4 (ctype-sizeof (_f32vector i)) = 4 (ctype-sizeof (_f32vector o 4)) = (* 4 4) (ctype-sizeof (_f32vector io 4)) = (* 4 4) (local [(define-cstruct _float4 ([f0 _float] [f1 _float] [f2 _float] [f3 _float]))] (test (ctype-sizeof _float4) = 16))) Output is: test: 5/11 test failures: unsaved-editor4119:11:1: test failure in (ctype-sizeof (_cvector i _float)) expected: 4 got: error: expand: unbound identifier in module unsaved-editor4119:12:1: test failure in (ctype-sizeof (_cvector o _float 4)) expected: 16 got: 4 unsaved-editor4119:13:1: test failure in (ctype-sizeof (_cvector io _float 4)) expected: 16 got: error: expand: unbound identifier in module unsaved-editor4119:17:1: test failure in (ctype-sizeof (_f32vector o 4)) expected: 16 got: 4 unsaved-editor4119:18:1: test failure in (ctype-sizeof (_f32vector io 4)) expected: 16 got: error: expand: unbound identifier in module Normally I would just go do this, but I don't really understand the FFI. If someone can point me appropriately, I'll go do it. Jay -- Jay McCarthy j...@cs.byu.edu Assistant Professor / Brigham Young University http://teammccarthy.org/jay The glory of God is Intelligence - DC 93 _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev -- Jay McCarthy j...@cs.byu.edu Assistant Professor / Brigham Young University
Re: [racket-dev] slideshow not hiding KDE panel
On Thu, Sep 30, 2010 at 6:47 PM, Matthew Flatt mfl...@cs.utah.edu wrote: At Thu, 30 Sep 2010 20:20:07 -0400, Faré wrote: I'm trying to use slideshow on Linux, and I find it annoying that it fails to be on top of the KDE panel. I admit I know next to nothing about the X protocol, and can't help much with this issue, but I hope someone who does can do something about it. For the record, samth says he has the exact same problem with the GNOME panel. I think I could fix this in GRacket2 if I could figure out how to provoke the bad behavior on my machine. I'm running Ubuntu 10, and Slideshow works. I tried installing and running Maximus, but Slideshow still worked. (Robby showed me bad behavior on his netbook, and I thought it had something to do with Maximus, but it's apparently not as simple as that.) Does anyone know what I can do to trigger the problem? This happens for me always in slideshow on my laptop in both GR1 and GR2. I'm running Ubuntu 10.04, screen resolution 1440x1050, with panels on the top and bottom of the screen (as is usual for Gnome). I can provide any other data as desired. -- sam th sa...@ccs.neu.edu _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev