-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from hoelzro/master
Expose errno and POSIX errno values to NQP
- Loading branch information
Showing
7 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,4 @@ config.status | |
config.default | ||
3rdparty/dyncall/ConfigVars | ||
3rdparty/dyncall/*/*.a | ||
/nqp_const.pir |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
plan(3); | ||
|
||
sub mkdir($filename) { | ||
pir::new__PS('OS').mkdir($filename, 0o777); | ||
return True; | ||
CATCH { | ||
return False; | ||
} | ||
} | ||
|
||
sub rmdir($filename) { | ||
pir::new__PS('OS').rmdir($filename); | ||
return True; | ||
CATCH { | ||
return False; | ||
} | ||
} | ||
|
||
my $test-dir := 'errno-test-dir'; | ||
|
||
rmdir($test-dir); | ||
ok(mkdir($test-dir) eq True, 'mkdir should succeed'); | ||
ok(mkdir($test-dir) eq False, 'mkdir of an existing directory should fail'); | ||
ok(nqp::x_posixerrno() == pir::const::POSIX_EEXIST, 'errno should be equal to EEXIST'); | ||
|
||
rmdir($test-dir); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use POSIX; | ||
|
||
print <<"END_HEADER"; | ||
# DO NOT EDIT THIS FILE. | ||
# | ||
# This file is generated automatically from | ||
# $0 | ||
# | ||
# Any changes made here will be lost. | ||
# | ||
END_HEADER | ||
|
||
my @errno_values; | ||
|
||
my $max_errno_name_len = 0; | ||
foreach my $name (sort grep { /^E[A-Z]+$/ } keys %POSIX::) { | ||
my $code = POSIX->can($name); | ||
|
||
next unless $code; | ||
|
||
my $value = eval { $code->() }; | ||
|
||
next unless defined $value; | ||
|
||
push @errno_values, [ $name, $value ]; | ||
|
||
if(length($name) > $max_errno_name_len) { | ||
$max_errno_name_len = length($name); | ||
} | ||
} | ||
|
||
my $format = ".macro_const POSIX_%-${max_errno_name_len}s %d\n"; | ||
|
||
foreach my $pair (@errno_values) { | ||
my ( $name, $value ) = @$pair; | ||
|
||
printf $format, $name, $value; | ||
} |