This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| struct Hoge { | |
| char c; | |
| int a[]; | |
| }; | |
| int main(void){ | |
| struct Hoge *hoge = malloc(sizeof(struct Hoge) + sizeof(int) * 10); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) | |
| #define container_of(ptr, type, member) ({ \ | |
| const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | |
| (type *)( (char *)__mptr - offsetof(type, member) );}) | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| struct T1 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "date" | |
| d1 = Date.new(2012, 2, -1) | |
| d2 = Date.new(2014, 12, 25) | |
| def binary?(n) | |
| if(n < 2) | |
| return true if n == 1 | |
| return false | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| typedef unsigned char typeS; | |
| struct S { | |
| typeS a: 1; | |
| typeS b: 1; | |
| typeS c: 1; | |
| typeS d: 1; | |
| typeS e: 1; | |
| typeS f: 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| /* | |
| using built-in specs. | |
| Target: x86_64-linux-gnu | |
| Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.5-8' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu | |
| Thread model: posix | |
| gcc version 4.4.5 (Debian 4.4.5-8) | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Control.Monad.Instances | |
| let f = (*2) >>= ¥a -> (*3) >>= ¥b -> return (a+b) :: Int -> Int | |
| f 10 #=> 50 | |
| Memo: | |
| Reader monad has a context that is passed some value and returns a value - a function, function as monad is called Reader. We can combinate functions and construct a bigger one. | |
| (*2) is a function and therefore a monadic value in Reader monad context. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // What is the best solution? ... | |
| // using macro .. ? | |
| #include <stdio.h> | |
| struct PrivateHoge { | |
| int y; | |
| }; | |
| struct PublicHoge { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Prelude Control.Applicative> :t (<*) | |
| (<*) :: Applicative f => f a -> f b -> f a | |
| Prelude Control.Applicative> :t (*>) | |
| (*>) :: Applicative f => f a -> f b -> f b | |
| Prelude Control.Applicative> :t (<**>) | |
| (<**>) :: Applicative f => f a -> f (a -> b) -> f b | |
| Prelude Control.Applicative> :t (<$) | |
| (<$) :: Functor f => a -> f b -> f a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ 2905.041900] device-mapper: lc: io err occurs err(-5), err_bits(1) | |
| [ 2905.041903] device-mapper: lc: rw(1), sector(100160376), dev(253:1) | |
| [ 2906.041540] device-mapper: lc: io has just turned fail to OK. | |
| [ 2906.041546] device-mapper: lc: rw(1), sector(100160376), dev(253:1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --2.6.30.1-- | |
| /home/akira/src/dm-lc/dm-lc.c:154: error: implicit declaration of function 'INIT_WORK_ONSTACK' | |
| /home/akira/src/dm-lc/dm-lc.c:1665: error: expected declaration specifiers or '...' before 'iterate_devices_callout_fn' | |
| /home/akira/src/dm-lc/dm-lc.c:1671: error: implicit declaration of function 'fn' | |
| /home/akira/src/dm-lc/dm-lc.c:1676: error: implicit declaration of function 'blk_limits_io_min' | |
| /home/akira/src/dm-lc/dm-lc.c:1677: error: implicit declaration of function 'blk_limits_io_opt' | |
| /home/akira/src/dm-lc/dm-lc.c:1709: error: unknown field 'io_hints' specified in initializer | |
| /home/akira/src/dm-lc/dm-lc.c:1710: error: unknown field 'iterate_devices' specified in initializer | |
| /home/akira/src/dm-lc/dm-lc.c:1993: error: too few arguments to function 'dm_io_client_create' | |
| --2.6.32.60-- |