Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit a159f249 authored by Alexander Martinz's avatar Alexander Martinz
Browse files

axolotl: switch to libcomparetf2_shim from lineage compat



Change-Id: I43392866119457e9c45f99f605992aa02aac82e2
Signed-off-by: Alexander Martinz's avatarAlexander Martinz <amartinz@shiftphones.com>
parent b9891ade
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -507,7 +507,7 @@ PRODUCT_PACKAGES += \

# VNDK
PRODUCT_PACKAGES += \
    libcomparetf2 \
    libcomparetf2_shim \
    libgui_vendor \

# WiFi
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ function blob_fixup() {
            grep -q "libui_shim.so" "${2}" || "${PATCHELF}" --add-needed "libui_shim.so" "${2}"
            ;;
        vendor/lib64/hw/camera.qcom.so)
            grep -q "libcomparetf2.so" "${2}" || "${PATCHELF}" --add-needed "libcomparetf2.so" "${2}"
            grep -q "libcomparetf2_shim.so" "${2}" || "${PATCHELF}" --add-needed "libcomparetf2_shim.so" "${2}"
            ;;
    esac
}

libshims/Android.bp

deleted100644 → 0
+0 −12
Original line number Diff line number Diff line
//
// Copyright (C) 2021 The LineageOS Project
//
// SPDX-License-Identifier: Apache-2.0
//

cc_library {
    name: "libcomparetf2",
    srcs: ["comparetf2.c"],
    compile_multilib: "64",
    vendor: true,
}

libshims/comparetf2.c

deleted100644 → 0
+0 −71
Original line number Diff line number Diff line
//===-- lib/comparetf2.c - Quad-precision comparisons -------------*- C -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <limits.h>

typedef __uint128_t rep_t;
typedef __int128_t srep_t;
typedef long double fp_t;

#define REP_C (__uint128_t)
#define typeWidth (sizeof(rep_t) * CHAR_BIT)
#define significandBits 112
#define exponentBits (typeWidth - significandBits - 1)

#define implicitBit (REP_C(1) << significandBits)
#define significandMask (implicitBit - 1U)
#define signBit (REP_C(1) << (significandBits + exponentBits))
#define absMask (signBit - 1U)
#define exponentMask (absMask ^ significandMask)
#define infRep exponentMask

static __inline rep_t toRep(fp_t x) {
  const union {
    fp_t f;
    rep_t i;
  } rep = {.f = x};
  return rep.i;
}

enum LE_RESULT { LE_LESS = -1, LE_EQUAL = 0, LE_GREATER = 1, LE_UNORDERED = 1 };

enum LE_RESULT __lttf2(fp_t a, fp_t b) {

  const srep_t aInt = toRep(a);
  const srep_t bInt = toRep(b);
  const rep_t aAbs = aInt & absMask;
  const rep_t bAbs = bInt & absMask;

  // If either a or b is NaN, they are unordered.
  if (aAbs > infRep || bAbs > infRep)
    return LE_UNORDERED;

  // If a and b are both zeros, they are equal.
  if ((aAbs | bAbs) == 0)
    return LE_EQUAL;

  // If at least one of a and b is positive, we get the same result comparing
  // a and b as signed integers as we would with a floating-point compare.
  if ((aInt & bInt) >= 0) {
    if (aInt < bInt)
      return LE_LESS;
    else if (aInt == bInt)
      return LE_EQUAL;
    else
      return LE_GREATER;
  } else {
    // Otherwise, both are negative, so we need to flip the sense of the
    // comparison to get the correct result.  (This assumes a twos- or ones-
    // complement integer representation; if integers are represented in a
    // sign-magnitude representation, then this flip is incorrect).
    if (aInt > bInt)
      return LE_LESS;
    else if (aInt == bInt)
      return LE_EQUAL;
    else
      return LE_GREATER;
  }
}