Narrow native bridge to clone_for_fork

We are removing native bridge copy of fork.cpp, but need to
replace call to clone() when it's done for bionic's fork.

The code here will run all pre-/post-clone routines for *guest*,
while native bridge implementation will need to run the
corresponding *host* routines.

Bug: 145028007
Test: bionic-unit-tests
Merged-In: Ic5524e743caa287d7aaa8dc7e5d34acd1c7e1170
Change-Id: Ic5524e743caa287d7aaa8dc7e5d34acd1c7e1170
(cherry picked from commit 41127dca3d08e5eb350b678ee03eae30ab779921)
diff --git a/libc/bionic/fork.cpp b/libc/bionic/fork.cpp
index cda5e85..c9a1ca8 100644
--- a/libc/bionic/fork.cpp
+++ b/libc/bionic/fork.cpp
@@ -34,22 +34,23 @@
 #include "pthread_internal.h"
 
 __BIONIC_WEAK_FOR_NATIVE_BRIDGE
+int __clone_for_fork() {
+  pthread_internal_t* self = __get_thread();
+
+  return clone(nullptr, nullptr, (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD), nullptr,
+               nullptr, nullptr, &(self->tid));
+}
+
+__BIONIC_WEAK_FOR_NATIVE_BRIDGE
 int fork() {
   __bionic_atfork_run_prepare();
 
-  pthread_internal_t* self = __get_thread();
+  int result = __clone_for_fork();
 
-  int result = clone(nullptr,
-                     nullptr,
-                     (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD),
-                     nullptr,
-                     nullptr,
-                     nullptr,
-                     &(self->tid));
   if (result == 0) {
     // Update the cached pid, since clone() will not set it directly (as
     // self->tid is updated by the kernel).
-    self->set_cached_pid(gettid());
+    __get_thread()->set_cached_pid(gettid());
 
     // Disable fdsan post-fork, so we don't falsely trigger on processes that
     // fork, close all of their fds blindly, and then exec.