Last active
May 7, 2018 06:10
-
-
Save aw/4ca813f8571fda85b20bacfd50f84f07 to your computer and use it in GitHub Desktop.
Revisions
-
aw renamed this gist
May 7, 2018 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,14 @@ ### PicoLisp's (native) can be used to create files atomically The C equivalent would be: ```C open("atomic.file", O_RDWR|O_CREAT|O_EXCL, 0644); ``` PicoLisp: ```picolisp # The flags can be read from sysdefs, but here we define them manually (Linux) (setq O_RDWR 2 #(in '("@src64/sysdefs") (from "O_RDWR") (read)) -
aw revised this gist
May 6, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ ### PicoLisp's (native) can be used to create files atomically ``` # The flags can be read from sysdefs, but here we define them manually (Linux) (setq O_RDWR 2 #(in '("@src64/sysdefs") (from "O_RDWR") (read)) -
aw revised this gist
May 6, 2018 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ ### PicoLisp's (native) can be used to create files atomically ```picolisp # The flags can be read from sysdefs, but here we define them manually (Linux) (setq O_RDWR 2 #(in '("@src64/sysdefs") (from "O_RDWR") (read)) @@ -12,5 +13,6 @@ # -> 3 (native "@" "open" 'I "atomic.file" (| O_RDWR O_CREAT O_EXCL) (oct "0644")) # -> -1 ``` First call is successful (3), second call fails (-1), as expected. -
aw created this gist
May 6, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ # PicoLisp's (native) can be used to create files atomically # The flags can be read from sysdefs, but here we define them manually (Linux) (setq O_RDWR 2 #(in '("@src64/sysdefs") (from "O_RDWR") (read)) O_CREAT 64 #(in '("@src64/sysdefs") (from "O_CREAT") (read)) O_EXCL 128 #(in '("@src64/sysdefs") (from "O_EXCL") (read)) ) # The file mode 0644 is octal and must be converted to int (native "@" "open" 'I "atomic.file" (| O_RDWR O_CREAT O_EXCL) (oct "0644")) # -> 3 (native "@" "open" 'I "atomic.file" (| O_RDWR O_CREAT O_EXCL) (oct "0644")) # -> -1 First call is successful, second call fails (-1), as expected.