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

Commit 6457359f authored by Mathias Agopian's avatar Mathias Agopian
Browse files

Merge commit 'goog/master' into merge_master

parents e839d826 d23399d0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -7,7 +7,9 @@
#include "ServiceManager.h"
#include "SignalHandler.h"

#include <utils.h>
#include <utils/threads.h>
#include <utils/Errors.h>

#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <utils/Log.h>  
+4 −1
Original line number Diff line number Diff line
@@ -20,7 +20,10 @@

#include <utils/String8.h>
#include <utils/threads.h>
#include <utils.h>
#include <utils/Log.h>
#include <utils/threads.h>
#include <utils/List.h>
#include <utils/Errors.h>

#include <linux/input.h>

include/utils.h

deleted100644 → 0
+0 −33
Original line number Diff line number Diff line
/*
 * Copyright (C) 2005 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//
// Handy utility functions and portability code.  This file includes all
// of the generally-useful headers in the "utils" directory.
//
#ifndef _LIBS_UTILS_H
#define _LIBS_UTILS_H

#include <utils/ported.h>
#include <utils/Log.h>
#include <utils/threads.h>
#include <utils/Timers.h>
#include <utils/List.h>
#include <utils/string_array.h>
#include <utils/misc.h>
#include <utils/Errors.h>

#endif // _LIBS_UTILS_H

include/utils/Pipe.h

deleted100644 → 0
+0 −108
Original line number Diff line number Diff line
/*
 * Copyright (C) 2005 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//
// FIFO I/O.
//
#ifndef _LIBS_UTILS_PIPE_H
#define _LIBS_UTILS_PIPE_H

#ifdef HAVE_ANDROID_OS
#error DO NOT USE THIS FILE IN THE DEVICE BUILD
#endif

namespace android {

/*
 * Simple anonymous unidirectional pipe.
 *
 * The primary goal is to create an implementation with minimal overhead
 * under Linux.  Making Windows, Mac OS X, and Linux all work the same way
 * is a secondary goal.  Part of this goal is to have something that can
 * be fed to a select() call, so that the application can sleep in the
 * kernel until something interesting happens.
 */
class Pipe {
public:
    Pipe(void);
    virtual ~Pipe(void);

    /* Create the pipe */
    bool create(void);

    /* Create a read-only pipe, using the supplied handle as read handle */
    bool createReader(unsigned long handle);
    /* Create a write-only pipe, using the supplied handle as write handle */
    bool createWriter(unsigned long handle);

    /* Is this object ready to go? */
    bool isCreated(void);

    /*
     * Read "count" bytes from the pipe.  Returns the amount of data read,
     * or 0 if no data available and we're non-blocking.
     * Returns -1 on error.
     */
    int read(void* buf, int count);

    /*
     * Write "count" bytes into the pipe.  Returns number of bytes written,
     * or 0 if there's no room for more data and we're non-blocking.
     * Returns -1 on error.
     */
    int write(const void* buf, int count);

    /* Returns "true" if data is available to read */
    bool readReady(void);

    /* Enable or disable non-blocking I/O for reads */
    bool setReadNonBlocking(bool val);
    /* Enable or disable non-blocking I/O for writes.  Only works on Linux. */
    bool setWriteNonBlocking(bool val);

    /*
     * Get the handle.  Only useful in some platform-specific situations.
     */
    unsigned long getReadHandle(void);
    unsigned long getWriteHandle(void);

    /*
     * Modify inheritance, i.e. whether or not a child process will get
     * copies of the descriptors.  Systems with fork+exec allow us to close
     * the descriptors before launching the child process, but Win32
     * doesn't allow it.
     */
    bool disallowReadInherit(void);
    bool disallowWriteInherit(void);

    /*
     * Close one side or the other.  Useful in the parent after launching
     * a child process.
     */
    bool closeRead(void);
    bool closeWrite(void);

private:
    bool    mReadNonBlocking;
    bool    mWriteNonBlocking;

    unsigned long mReadHandle;
    unsigned long mWriteHandle;
};

}; // android

#endif // _LIBS_UTILS_PIPE_H

include/utils/TimerProbe.h

deleted100644 → 0
+0 −72
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_TIMER_PROBE_H
#define ANDROID_TIMER_PROBE_H

#if 0 && defined(HAVE_POSIX_CLOCKS)
#define ENABLE_TIMER_PROBE 1
#else
#define ENABLE_TIMER_PROBE 0
#endif

#if ENABLE_TIMER_PROBE

#include <time.h>
#include <sys/time.h>
#include <utils/Vector.h>

#define TIMER_PROBE(tag) \
    static int _timer_slot_; \
    android::TimerProbe probe(tag, &_timer_slot_)
#define TIMER_PROBE_END() probe.end()
#else
#define TIMER_PROBE(tag)
#define TIMER_PROBE_END()
#endif

#if ENABLE_TIMER_PROBE
namespace android {

class TimerProbe {
public:
    TimerProbe(const char tag[], int* slot);
    void end();
    ~TimerProbe();
private:
    struct Bucket {
        int mStart, mReal, mProcess, mThread, mCount;
        const char* mTag;
        int* mSlotPtr;
        int mIndent;
    };
    static Vector<Bucket> gBuckets;
    static TimerProbe* gExecuteChain;
    static int gIndent;
    static timespec gRealBase;
    TimerProbe* mNext;
    static uint32_t ElapsedTime(const timespec& start, const timespec& end);
    void print(const timespec& r, const timespec& p, const timespec& t) const;
    timespec mRealStart, mPStart, mTStart;
    const char* mTag;
    int mIndent;
    int mBucket;
};

}; // namespace android

#endif
#endif
Loading