-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ba8036
commit 22a232d
Showing
2 changed files
with
43 additions
and
85 deletions.
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 |
---|---|---|
@@ -1,48 +1,44 @@ | ||
# From https://github.com/cern-eos/eos/blob/master/cmake/FindAtomic.cmake | ||
# License: GPL-3-or-later | ||
# Try to find libatomic | ||
# Once done, this will define | ||
# | ||
# ATOMIC_FOUND - system has libatomic | ||
# ATOMIC_LIBRARIES - libraries needed to use libatomic | ||
# | ||
# based on | ||
# https://raw.githubusercontent.com/eProsima/Fast-DDS/d607eefc91e2623cde8bc71d14f275ac57ba5c4f/cmake/modules/FindAtomic.cmake | ||
# license: Apache-2.0 | ||
|
||
include(CheckCXXSourceCompiles) | ||
|
||
check_cxx_source_compiles(" | ||
int main() { | ||
volatile unsigned __int128 all_ = 4; | ||
__atomic_fetch_add(&all_, 8, __ATOMIC_RELAXED); | ||
return 0; | ||
} | ||
" | ||
ATOMIC_LIBRARY_NATIVE) | ||
int main() { | ||
volatile unsigned __int128 i = 4; | ||
__atomic_fetch_add(&i, 8, __ATOMIC_RELAXED); | ||
__atomic_fetch_sub(&i, 8, __ATOMIC_RELAXED); | ||
return 0; | ||
}" | ||
ATOMIC_NATIVE | ||
) | ||
|
||
if (ATOMIC_LIBRARY_NATIVE) | ||
set(ATOMIC_FOUND 1) | ||
set(ATOMIC_LIBRARY) | ||
if (ATOMIC_NATIVE) | ||
set(ATOMIC_FOUND 1) | ||
set(ATOMIC_LIBRARY) | ||
else () | ||
set(CMAKE_REQUIRED_LIBRARIES "-latomic") | ||
set(_OLD_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") | ||
set(CMAKE_REQUIRED_LIBRARIES "-latomic") | ||
check_cxx_source_compiles(" | ||
int main() { | ||
volatile unsigned __int128 all_ = 4; | ||
__atomic_fetch_add(&all_, 8, __ATOMIC_RELAXED); | ||
return 0; | ||
} | ||
" | ||
ATOMIC_LIBRARY_LIB) | ||
set(CMAKE_REQUIRED_LIBRARIES) | ||
if (ATOMIC_LIBRARY_LIB) | ||
set(ATOMIC_FOUND 1) | ||
set(ATOMIC_LIBRARY atomic) | ||
else () | ||
find_library(ATOMIC_LIBRARY | ||
NAMES atomic atomic.so.1 libatomic.so.1 libatomic.dylib libatomic.1.dylib libatomic.a | ||
HINTS ${ATOMIC_ROOT} | ||
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR}) | ||
int main() { | ||
volatile unsigned __int128 i = 4; | ||
__atomic_fetch_add(&i, 8, __ATOMIC_RELAXED); | ||
__atomic_fetch_sub(&i, 8, __ATOMIC_RELAXED); | ||
return 0; | ||
}" | ||
ATOMIC_WITH_LIB | ||
) | ||
set(CMAKE_REQUIRED_LIBRARIES "${_OLD_CMAKE_REQUIRED_LIBRARIES}") | ||
unset(_OLD_CMAKE_REQUIRED_LIBRARIES) | ||
if (ATOMIC_WITH_LIB) | ||
set(ATOMIC_FOUND 1) | ||
set(ATOMIC_LIBRARY -latomic) | ||
endif () | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Atomic DEFAULT_MSG ATOMIC_LIBRARY) | ||
endif () | ||
|
||
set(ATOMIC_LIBRARIES ${ATOMIC_LIBRARY}) | ||
unset(ATOMIC_LIBRARY) | ||
unset(ATOMIC_WITH_LIB) | ||
unset(ATOMIC_NATIVE) |
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 |
---|---|---|
@@ -1,56 +1,18 @@ | ||
#!/usr/bin/env perl | ||
# | ||
# xxdi.pl - perl implementation of 'xxd -i' mode | ||
# | ||
# Copyright 2013 Greg Kroah-Hartman <[email protected]> | ||
# Copyright 2013 Linux Foundation | ||
# | ||
# Released under the GPLv2. | ||
# | ||
# Implements the "basic" functionality of 'xxd -i' in perl to keep build | ||
# systems from having to build/install/rely on vim-core, which not all | ||
# distros want to do. But everyone has perl, so use it instead. | ||
# | ||
|
||
use strict; | ||
use warnings; | ||
sub slurp { | ||
my $file = shift; | ||
open my $fh, '<', $file or die; | ||
local $/ = undef; | ||
my $cont = <$fh>; | ||
close $fh; | ||
return $cont; | ||
} | ||
my $indata = slurp(@ARGV ? $ARGV[0] : \*STDIN); | ||
my $len_data = length($indata); | ||
my $num_digits_per_line = 12; | ||
my $var_name; | ||
my $outdata; | ||
|
||
# Use the variable name of the file we read from, converting '/' and '. | ||
# to '_', or, if this is stdin, just use "stdin" as the name. | ||
if (@ARGV) { | ||
$var_name = $ARGV[0]; | ||
$var_name =~ s/\//_/g; | ||
$var_name =~ s/\./_/g; | ||
} else { | ||
$var_name = "stdin"; | ||
} | ||
my $file = shift; | ||
open my $input, '<', $file or die "Can't open file for read: $file $!"; | ||
my $text = do { local $/; <$input> }; | ||
close $input; | ||
|
||
$outdata .= "unsigned char $var_name\[] = {"; | ||
|
||
# trailing ',' is acceptable, so instead of duplicating the logic for | ||
# just the last character, live with the extra ','. | ||
for (my $key= 0; $key < $len_data; $key++) { | ||
if ($key % $num_digits_per_line == 0) { | ||
$outdata .= "\n\t"; | ||
} | ||
$outdata .= sprintf("0x%.2x, ", ord(substr($indata, $key, 1))); | ||
} | ||
|
||
$outdata .= "\n};\nunsigned int $var_name\_len = $len_data;\n"; | ||
|
||
binmode STDOUT; | ||
print {*STDOUT} $outdata; | ||
my @hex_values = map { "0x$_" } unpack("(H2)*", $text); | ||
my $hex_data = join(",", map { ($_ % 16 == 0 ? "\n\t" : "") . $hex_values[$_] } 0 .. $#hex_values); | ||
my $len_data = length($text); | ||
|
||
my $varname = $file; | ||
$varname =~ s/[\/.]/_/g; | ||
print "unsigned char $varname\[\] = { $hex_data \n};\n"; | ||
print "unsigned int ${varname}_len = $len_data;\n"; |