diff options
author | Thomas Bertschinger <tahbertschinger@gmail.com> | 2024-01-15 23:41:02 -0700 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-16 01:47:05 -0500 |
commit | f5baaf48e3e82b1caf9f5cd1207d4d6feba3a2e5 (patch) | |
tree | 59f7b0e4667df7a9d3d5a45725f2aaab3e79b4c5 /c_src/raid/tag.c | |
parent | fb35dbfdc5a9446fbb856dae5542b23963e28b89 (diff) |
move Rust sources to top level, C sources into c_src
This moves the Rust sources out of rust_src/ and into the top level.
Running the bcachefs executable out of the development tree is now:
$ ./target/release/bcachefs command
or
$ cargo run --profile release -- command
instead of "./bcachefs command".
Building and installing is still:
$ make && make install
Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'c_src/raid/tag.c')
-rw-r--r-- | c_src/raid/tag.c | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/c_src/raid/tag.c b/c_src/raid/tag.c new file mode 100644 index 00000000..bfeefaad --- /dev/null +++ b/c_src/raid/tag.c @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2013 Andrea Mazzoleni + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "internal.h" + +static struct raid_func { + const char *name; + void (*p)(); +} RAID_FUNC[] = { + { "int8", raid_gen3_int8 }, + { "int8", raid_gen4_int8 }, + { "int8", raid_gen5_int8 }, + { "int8", raid_gen6_int8 }, + { "int32", raid_gen1_int32 }, + { "int64", raid_gen1_int64 }, + { "int32", raid_gen2_int32 }, + { "int64", raid_gen2_int64 }, + { "int32", raid_genz_int32 }, + { "int64", raid_genz_int64 }, + { "int8", raid_rec1_int8 }, + { "int8", raid_rec2_int8 }, + { "int8", raid_recX_int8 }, + +#ifdef CONFIG_X86 +#ifdef CONFIG_SSE2 + { "sse2", raid_gen1_sse2 }, + { "sse2", raid_gen2_sse2 }, + { "sse2", raid_genz_sse2 }, +#endif +#ifdef CONFIG_SSSE3 + { "ssse3", raid_gen3_ssse3 }, + { "ssse3", raid_gen4_ssse3 }, + { "ssse3", raid_gen5_ssse3 }, + { "ssse3", raid_gen6_ssse3 }, + { "ssse3", raid_rec1_ssse3 }, + { "ssse3", raid_rec2_ssse3 }, + { "ssse3", raid_recX_ssse3 }, +#endif +#ifdef CONFIG_AVX2 + { "avx2", raid_gen1_avx2 }, + { "avx2", raid_gen2_avx2 }, + { "avx2", raid_rec1_avx2 }, + { "avx2", raid_rec2_avx2 }, + { "avx2", raid_recX_avx2 }, +#endif +#endif + +#ifdef CONFIG_X86_64 +#ifdef CONFIG_SSE2 + { "sse2e", raid_gen2_sse2ext }, + { "sse2e", raid_genz_sse2ext }, +#endif +#ifdef CONFIG_SSSE3 + { "ssse3e", raid_gen3_ssse3ext }, + { "ssse3e", raid_gen4_ssse3ext }, + { "ssse3e", raid_gen5_ssse3ext }, + { "ssse3e", raid_gen6_ssse3ext }, +#endif +#ifdef CONFIG_AVX2 + { "avx2e", raid_gen3_avx2ext }, + { "avx2e", raid_genz_avx2ext }, + { "avx2e", raid_gen4_avx2ext }, + { "avx2e", raid_gen5_avx2ext }, + { "avx2e", raid_gen6_avx2ext }, +#endif +#endif + { 0, 0 } +}; + +static const char *raid_tag(void (*func)()) +{ + struct raid_func *i = RAID_FUNC; + + while (i->name != 0) { + if (i->p == func) + return i->name; + ++i; + } + + /* LCOV_EXCL_START */ + return "unknown"; + /* LCOV_EXCL_STOP */ +} + +const char *raid_gen1_tag(void) +{ + return raid_tag(raid_gen_ptr[0]); +} + +const char *raid_gen2_tag(void) +{ + return raid_tag(raid_gen_ptr[1]); +} + +const char *raid_genz_tag(void) +{ + return raid_tag(raid_genz_ptr); +} + +const char *raid_gen3_tag(void) +{ + return raid_tag(raid_gen_ptr[2]); +} + +const char *raid_gen4_tag(void) +{ + return raid_tag(raid_gen_ptr[3]); +} + +const char *raid_gen5_tag(void) +{ + return raid_tag(raid_gen_ptr[4]); +} + +const char *raid_gen6_tag(void) +{ + return raid_tag(raid_gen_ptr[5]); +} + +const char *raid_rec1_tag(void) +{ + return raid_tag(raid_rec_ptr[0]); +} + +const char *raid_rec2_tag(void) +{ + return raid_tag(raid_rec_ptr[1]); +} + +const char *raid_recX_tag(void) +{ + return raid_tag(raid_rec_ptr[2]); +} + |