sn_comparator.h   sn_comparator.h 
skipping to change at line 31 skipping to change at line 31
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* Authors: * Authors:
* Florian octo Forster <ff at octo.it> * Florian octo Forster <ff at octo.it>
* \endverbatim * \endverbatim
**/ **/
#ifndef SN_COMPARATOR_H #ifndef SN_COMPARATOR_H
#define SN_COMPARATOR_H 1 #define SN_COMPARATOR_H 1
#include <stdint.h>
#include <inttypes.h>
/** /**
* Struct representing a comparator. Don't access the members of this struc t * Struct representing a comparator. Don't access the members of this struc t
* directly, use the macros below instead. * directly, use the macros below instead.
*/ */
struct sn_comparator_s struct sn_comparator_s
{ {
int min; /**< Index of the line onto which the smaller element will be pu t. */ int min; /**< Index of the line onto which the smaller element will be pu t. */
int max; /**< Index of the line onto which the larger element will be put . */ int max; /**< Index of the line onto which the larger element will be put . */
void *user_data; /**< Pointer to user data. */ void *user_data; /**< Pointer to user data. */
void (*free_func) (void *); /**< Pointer to a function used to free the u ser data pointer. */ void (*free_func) (void *); /**< Pointer to a function used to free the u ser data pointer. */
skipping to change at line 117 skipping to change at line 120
* Compares two comparators and returns less than zero, zero, or greater th an * Compares two comparators and returns less than zero, zero, or greater th an
* zero if the first comparator is smaller than, equal to or larger than th e * zero if the first comparator is smaller than, equal to or larger than th e
* second comparator, respectively. * second comparator, respectively.
* *
* \param c0 Pointer to the first comparator. * \param c0 Pointer to the first comparator.
* \param c1 Pointer to the second comparator. * \param c1 Pointer to the second comparator.
*/ */
int sn_comparator_compare (const sn_comparator_t *c0, int sn_comparator_compare (const sn_comparator_t *c0,
const sn_comparator_t *c1); const sn_comparator_t *c1);
uint64_t sn_comparator_get_hashval (const sn_comparator_t *c);
#endif /* SN_COMPARATOR_H */ #endif /* SN_COMPARATOR_H */
/* vim: set shiftwidth=2 softtabstop=2 : */ /* vim: set shiftwidth=2 softtabstop=2 : */
 End of changes. 2 change blocks. 
0 lines changed or deleted 5 lines changed or added


 sn_network.h   sn_network.h 
skipping to change at line 34 skipping to change at line 34
* *
* Authors: * Authors:
* Florian octo Forster <ff at octo.it> * Florian octo Forster <ff at octo.it>
* \endverbatim * \endverbatim
**/ **/
#ifndef SN_NETWORK_H #ifndef SN_NETWORK_H
#define SN_NETWORK_H 1 #define SN_NETWORK_H 1
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include "sn_comparator.h" #include "sn_comparator.h"
#include "sn_stage.h" #include "sn_stage.h"
/** /**
* The global struct representing a comparator or sort network. * The global struct representing a comparator or sort network.
*/ */
struct sn_network_s struct sn_network_s
{ {
int inputs_num; /**< Number of inputs of the comparator network. */ int inputs_num; /**< Number of inputs of the comparator network. */
skipping to change at line 197 skipping to change at line 199
int sn_network_brute_force_check (sn_network_t *n); int sn_network_brute_force_check (sn_network_t *n);
/** /**
* Prints the comparator network to \c STDOUT using a human readable * Prints the comparator network to \c STDOUT using a human readable
* representation. * representation.
* *
* \param n The comparator network to display. * \param n The comparator network to display.
* \return Zero on success, non-zero on failure. * \return Zero on success, non-zero on failure.
*/ */
int sn_network_show (sn_network_t *n); int sn_network_show (sn_network_t *n);
int sn_network_show_fh (sn_network_t *n, FILE *fh);
/** /**
* Inverts a comparator network by switching the direction of all comparato rs. * Inverts a comparator network by switching the direction of all comparato rs.
* *
* \param n The network to invert. * \param n The network to invert.
* \return Zero on success, non-zero on failure. * \return Zero on success, non-zero on failure.
*/ */
int sn_network_invert (sn_network_t *n); int sn_network_invert (sn_network_t *n);
/** /**
skipping to change at line 234 skipping to change at line 237
/** /**
* Converts a non-standard comparator network to a standard comparator netw ork, * Converts a non-standard comparator network to a standard comparator netw ork,
* i.e. a network in which all comparators point in the same direction. * i.e. a network in which all comparators point in the same direction.
* *
* \param n The network to normalize. * \param n The network to normalize.
* \return Zero on success, non-zero on failure. * \return Zero on success, non-zero on failure.
*/ */
int sn_network_normalize (sn_network_t *n); int sn_network_normalize (sn_network_t *n);
int sn_network_unify (sn_network_t *n);
/** /**
* Removes an input and all comparators touching that input from the compar ator * Removes an input and all comparators touching that input from the compar ator
* network. * network.
* *
* \param n The network to modify. * \param n The network to modify.
* \param input The zero-based index of the input to remove. * \param input The zero-based index of the input to remove.
* \return Zero on success, non-zero on failure. * \return Zero on success, non-zero on failure.
*/ */
int sn_network_remove_input (sn_network_t *n, int input); int sn_network_remove_input (sn_network_t *n, int input);
skipping to change at line 354 skipping to change at line 359
* Creates a comparator network from its serialized form. * Creates a comparator network from its serialized form.
* *
* \param buffer Pointer to a buffer containing the comparator network in * \param buffer Pointer to a buffer containing the comparator network in
* serialized form. * serialized form.
* \param buffer_size Size of the buffer (in bytes). * \param buffer_size Size of the buffer (in bytes).
* \return Pointer to the newly allocated comparator network or \c NULL on * \return Pointer to the newly allocated comparator network or \c NULL on
* error. * error.
* \see sn_network_serialize * \see sn_network_serialize
*/ */
sn_network_t *sn_network_unserialize (char *buffer, size_t buffer_size); sn_network_t *sn_network_unserialize (char *buffer, size_t buffer_size);
/**
* Compares two networks and returns zero if they are equal. If they are no
t
* equal, a number greater than zero or less than zero is returned in a
* consistent matter, so this function can be used to sort networks and det
ect
* duplicates. It is strongly recommended that you call sn_network_unify()
* before comparing two networks, because they internal structure does matt
er
* for this function.
*
* \return Zero if the two networks are equal, non-zero otherwise. Return
* values are consistent so this function can be used to sort networks.
* \see sn_network_unify
*/
int sn_network_compare (const sn_network_t *n0, const sn_network_t *n1);
uint64_t sn_network_get_hashval (const sn_network_t *n);
#endif /* SN_NETWORK_H */ #endif /* SN_NETWORK_H */
/* vim: set shiftwidth=2 softtabstop=2 : */ /* vim: set shiftwidth=2 softtabstop=2 : */
 End of changes. 4 change blocks. 
0 lines changed or deleted 25 lines changed or added


 sn_stage.h   sn_stage.h 
skipping to change at line 32 skipping to change at line 32
* *
* Authors: * Authors:
* Florian octo Forster <ff at octo.it> * Florian octo Forster <ff at octo.it>
* \endverbatim * \endverbatim
**/ **/
#ifndef SN_STAGE_H #ifndef SN_STAGE_H
#define SN_STAGE_H 1 #define SN_STAGE_H 1
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include "sn_comparator.h" #include "sn_comparator.h"
/** /**
* Struct representing a stage of the comparator network. Don't modify this * Struct representing a stage of the comparator network. Don't modify this
* struct yourself, use the sn_stage_* methods instead. * struct yourself, use the sn_stage_* methods instead.
*/ */
struct sn_stage_s struct sn_stage_s
{ {
int depth; /**< Depth of this stage, where zero means closest to the input. */ int depth; /**< Depth of this stage, where zero means closest to the input. */
skipping to change at line 144 skipping to change at line 146
int sn_stage_comparator_check_conflict (sn_stage_t *s, const sn_comparator_ t *c); int sn_stage_comparator_check_conflict (sn_stage_t *s, const sn_comparator_ t *c);
/** /**
* Prints the stage to \c STDOUT using a human readable representation. * Prints the stage to \c STDOUT using a human readable representation.
* *
* \param s The comparator network to display. * \param s The comparator network to display.
* \return Zero on success, non-zero on failure. * \return Zero on success, non-zero on failure.
* \see sn_network_show * \see sn_network_show
*/ */
int sn_stage_show (sn_stage_t *s); int sn_stage_show (sn_stage_t *s);
int sn_stage_show_fh (sn_stage_t *s, FILE *fh);
/** /**
* Inverts a stage by switching the direction of all comparators. * Inverts a stage by switching the direction of all comparators.
* *
* \param s The stage to invert. * \param s The stage to invert.
* \return Zero on success, non-zero on failure. * \return Zero on success, non-zero on failure.
* \see sn_network_invert * \see sn_network_invert
*/ */
int sn_stage_invert (sn_stage_t *s); int sn_stage_invert (sn_stage_t *s);
skipping to change at line 166 skipping to change at line 169
* higher inputs are "wrapped around". * higher inputs are "wrapped around".
* *
* \param s The stage to shift. * \param s The stage to shift.
* \param sw The number of positions to shift. * \param sw The number of positions to shift.
* \param inputs_num The number of inputs of the comparator network. This v alue * \param inputs_num The number of inputs of the comparator network. This v alue
* is used to "wrap around" inputs. * is used to "wrap around" inputs.
* \return Zero on success, non-zero on failure. * \return Zero on success, non-zero on failure.
*/ */
int sn_stage_shift (sn_stage_t *s, int sw, int inputs_num); int sn_stage_shift (sn_stage_t *s, int sw, int inputs_num);
int sn_stage_unify (sn_stage_t *s);
/** /**
* Swaps two lines. This is used by the algorithm used in * Swaps two lines. This is used by the algorithm used in
* sn_network_normalize() to transform non-standard sort networks to standa rd * sn_network_normalize() to transform non-standard sort networks to standa rd
* sort networks. * sort networks.
* *
* \param s The stage on which to operate. * \param s The stage on which to operate.
* \param con0 Index of the first line. * \param con0 Index of the first line.
* \param con1 Index of the second line. * \param con1 Index of the second line.
* \return Zero on success, non-zero on failure. * \return Zero on success, non-zero on failure.
* \see sn_network_normalize(), sn_comparator_swap() * \see sn_network_normalize(), sn_comparator_swap()
skipping to change at line 252 skipping to change at line 257
/** /**
* Creates a stage from its serialized form. * Creates a stage from its serialized form.
* *
* \param buffer Pointer to a buffer containing the stage in serialized for m. * \param buffer Pointer to a buffer containing the stage in serialized for m.
* \param buffer_size Size of the buffer (in bytes). * \param buffer_size Size of the buffer (in bytes).
* \return Pointer to the newly allocated stage or \c NULL on error. * \return Pointer to the newly allocated stage or \c NULL on error.
* \see sn_stage_serialize(), sn_network_unserialize() * \see sn_stage_serialize(), sn_network_unserialize()
*/ */
sn_stage_t *sn_stage_unserialize (char **buffer, size_t *buffer_size); sn_stage_t *sn_stage_unserialize (char **buffer, size_t *buffer_size);
int sn_stage_compare (const sn_stage_t *s0, const sn_stage_t *s1);
uint64_t sn_stage_get_hashval (const sn_stage_t *s);
#endif /* SN_STAGE_H */ #endif /* SN_STAGE_H */
/* vim: set shiftwidth=2 softtabstop=2 : */ /* vim: set shiftwidth=2 softtabstop=2 : */
 End of changes. 4 change blocks. 
0 lines changed or deleted 9 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/