Commit 2a921e2 1 parent cbc3162 commit 2a921e2 Copy full SHA for 2a921e2
File tree 4 files changed +90
-0
lines changed
4 files changed +90
-0
lines changed Original file line number Diff line number Diff line change @@ -777,6 +777,20 @@ cc_library(
777
777
],
778
778
)
779
779
780
+ # Library for C-wrappers of util.h.
781
+ cc_library (
782
+ name = "util_c" ,
783
+ srcs = ["util_c.cc" ],
784
+ hdrs = ["util_c.h" ],
785
+ copts = sapi_platform_copts (),
786
+ visibility = ["//visibility:public" ],
787
+ deps = [
788
+ ":util" ,
789
+ "@com_google_absl//absl/log" ,
790
+ "@com_google_absl//absl/status:statusor" ,
791
+ ],
792
+ )
793
+
780
794
cc_library (
781
795
name = "buffer" ,
782
796
srcs = ["buffer.cc" ],
Original file line number Diff line number Diff line change @@ -708,6 +708,19 @@ target_compile_options(sandbox2_util PRIVATE
708
708
-Wframe-larger-than=17000
709
709
)
710
710
711
+ # sandboxed_api/sandbox2:util_c
712
+ add_library (sandbox2_util_c ${SAPI_LIB_TYPE}
713
+ util_c.cc
714
+ util_c.h
715
+ )
716
+ add_library (sandbox2::util_c ALIAS sandbox2_util_c)
717
+ target_link_libraries (sandbox2_util_c
718
+ PRIVATE absl::statusor
719
+ absl::log
720
+ sandbox2::util
721
+ sapi::base
722
+ )
723
+
711
724
# sandboxed_api/sandbox2:buffer
712
725
add_library (sandbox2_buffer ${SAPI_LIB_TYPE}
713
726
buffer.cc
Original file line number Diff line number Diff line change
1
+ // Copyright 2025 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #include " sandboxed_api/sandbox2/util_c.h"
16
+
17
+ #include " absl/log/log.h"
18
+ #include " absl/status/statusor.h"
19
+ #include " sandboxed_api/sandbox2/util.h"
20
+
21
+ // Returns true if the current process is running inside Sandbox2.
22
+ bool IsRunningInSandbox2 () {
23
+ absl::StatusOr<bool > result = sandbox2::util::IsRunningInSandbox2 ();
24
+ if (!result.ok ()) {
25
+ LOG (ERROR) << result.status ();
26
+ return false ;
27
+ }
28
+ return *result;
29
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2025 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ // This header provides a C-wrapper for sandbox2::util functions that may be
16
+ // useful in C hostcode.
17
+
18
+ #ifndef SANDBOXED_API_SANDBOX2_UTIL_C_H_
19
+ #define SANDBOXED_API_SANDBOX2_UTIL_C_H_
20
+
21
+ #include <stdbool.h>
22
+
23
+ #if defined(__cplusplus )
24
+ extern "C" {
25
+ #endif
26
+
27
+ // Returns true if the current process is running inside Sandbox2.
28
+ bool IsRunningInSandbox2 ();
29
+
30
+ #if defined(__cplusplus )
31
+ } // extern "C"
32
+ #endif
33
+
34
+ #endif // SANDBOXED_API_SANDBOX2_UTIL_C_H_
You can’t perform that action at this time.
0 commit comments